Re: Important features for editors
On Fri, 05 Jul 2013 23:13:24 -0400, Rustom Mody wrote:Yes...The fact that rms has crippling RSI should indicate that emacs' ergonomics is not right. As someone crippled by Emacs ( actual cause not known), I should also point out that RMS, instead of doing the responsible thing and using speech recognition software, burns the hands of other human beings by using them as biological speech recognition units.Now for me, an important feature for editor is the ability to command it, not by keystrokes but by function/method invocation. This is be the first step to reducing the disasters caused by misrecognition events injecting unintentional commands into an editor. For example, bring up a file in VI in close your eyes and type some string like "save file" or "end of line". What kind of damage do you get? With an editor RPC, you can bypass all this damage. You turn off keystroke input at the start of a recognition event and all keyboard queue data is injected as characters. All commands are injected by the API.There's a few other things, I need in a very tiny editor to help a part of my accessibility problem. One of the ways I deal with speech recognition user interfaces by creating tiny domain specific languages to solve a problem. You can say them, they are resilient in the face of misrecognition, edit them and you can replay them. Bunch of wins. The tiny editor needs to use the right Windows edit control to work with NaturallySpeaking, save data so that I never have to think about it. It's always on disk, always safe. If I invoke a file by name, I get exactly one instance. And last, I want the ability to filter the contents of the editor through a bit of Python code so I can do transformations on opening the file or writing the file.Further down the road, instead of the classic syntax highlighting, I need dynamic naming of features so that I can say things like "replace third argument", "modify index" for format local times using pattern.I will admit the last one is a bit of a cheat because that's a subset of the domain specific notation I think that earlier. Not a solved problem :-)So important feature editor change depending on your perspective, or should I say, state of impending disability. We all become disabled with age, just some of us age much faster than the rest of the population-- http://mail.python.org/mailman/listinfo/python-list
Re: Editor Ergonomics [was: Important features for editors]
On Fri, 12 Jul 2013 00:24:26 -0400, Steven D'Aprano wrote: Frankly, nothing comes even close to a real mouse for feedback and ease of use. Maybe a stylus. But that's it. before tremors, I would agree with you. Stylus is amazingly good tool for user interaction in a GUI. After tremors, not so much. For example, when you sweep across the pad, you keep your mouse tip up, over and use feedback from your mouse pointer to tell you when to touch down. My tremors caused mouse clicks on tablet at about a 2 Hz rate. You can just imagine it, hearing me move the stylus across the pad going: Tap tap tap tap tap tap tap. Yeah, sucks to be me. A high-resolution mouse is similarly problematic because I can make a gross motion to another part of the screen. hitting a small target on a high-resolution screen is not easy in the least and usually takes longer than the gross positioning across the screen. What I would love is a mouse interface that uses a mouse motion for a small range but a force vector like Mr. eraser head for longer-range movement. Not exactly sure how the mouse would behave but that's a very rough idea what would work well with my hands. -- http://mail.python.org/mailman/listinfo/python-list
Re: Understanding other people's code
On Fri, 12 Jul 2013 10:22:59 -0400, L O'Shea wrote: Literally any idea will help, pen and paper, printing off all the code and doing some sort of highlighting session - anything! I keep reading bits of code and thinking "well where the hell has that been defined and what does it mean" to find it was inherited from 3 modules up the chain. I really need to get a handle on how exactly all this slots together! Any techniques,tricks or methodologies that people find useful would be much appreciated. glad to hear you're having a WTF moment (what's that function). Suggestion would be index cards, each containing notes on a class. truly understand what each parent class is in which methods are to be overloaded. Then look at one child and understand how it. Work your way breadth first down the inheritance tree. -- http://mail.python.org/mailman/listinfo/python-list
Re: Editor Ergonomics [was: Important features for editors]
On Fri, 12 Jul 2013 18:34:30 -0400, Dennis Lee Bieber wrote: Sounds like you might have liked an accessory I had on my Amiga. Basically a proportional joystick feeding an interface box which converted the position value into a sequence of mouse movements -- sounds very cool. Although after I wrote my little screed, I found myself fiddling with my smartphone and I realized I was subconsciously putting it through the motions if it was a positioning device. The gross motion is detected by the accelerometer's in the phone. The fine positioning by fingers on the screen. Just thinking out loud. -- http://mail.python.org/mailman/listinfo/python-list
Re: What does it take to implement a chat system in Python (Not asking for code just advice before I start my little project)
On Thu, 18 Jul 2013 00:36:17 -0400, Aseem Bansal wrote: I wanted to do a little project for learning Python. I thought a chat system will be good as it isn't something that I have ever done. I wanted to know what will I need? I think that would require me these 1 learn network/socket programming 2 find a free server to host my chat server 3 GUI development for clients Not discourage you but this is a "been there, done that" kind of project. You could learn more from reading somebody else is code. What hasn't been done, and this would be very cool, is a chat program that works peer-to-peer with no central server. To do this, you would probably need to know about distributed hash tables and methods of piercing address translation firewalls (think UDP). First however, I would suggest taking a look at https://jitsi.org/ and see how they do things. You can learn a lot from these people. They are very smart. -- http://mail.python.org/mailman/listinfo/python-list
Re: Simple Python script as SMTP server for outgoing e-mails?
On Mon, 22 Jul 2013 08:11:25 -0400, Gilles wrote: On Sun, 21 Jul 2013 18:28:27 -0600, Michael Torrie wrote: The Sendmail MTA has been ported to many platforms including windows. But... Thanks for the tip. Since I couldn't find a good, basic, native Windows app, I was indeed about to look at eg. Exim + Cygwin, and resort to a Linux appliance if none footed the bill. try http://emailrelay.sourceforge.net/ -- http://mail.python.org/mailman/listinfo/python-list
Re: [Savoynet] G&S Opera Co: Pirates of Penzance
On Sun, 28 Jul 2013 19:49:07 -0400, Ethan Furman wrote: On 07/28/2013 10:57 AM, Chris Angelico wrote: . . . Okay, how did you get confused that this was a Python List question? ;) got_a_little_list["victim must be found"] = http://www.youtube.com/watch?v=1NLV24qTnlg -- http://mail.python.org/mailman/listinfo/python-list
simplified Python parsing question
as some folks may remember, I have been working on making Python and its tool base more accessible to disabled programmers. I've finally come up with a really simple technique which should solve 80% of the problem. What I need to figure out is how to find a spot in the code where a symbol exists and potentially, it's rough type (class name, instance, etc.). This is really a much bigger question that I want to get into right now but I'm looking just to build a demo to back up a storyboard plus video. When you are sitting on or in a name, you look to the left or look to the right what would you see that would tell you that you have gone past the end of that name. For example a = b + c if you are sitting on a, the boundaries are beginning of line and =, if you are sitting on b, the boundaries are = and +, if you are sitting on c, the boundaries are + and end of line. a call the region between those boundaries the symbol region. if this example is clear to you, what you suggest for a method of finding a whole statement, or a whole symbol region? note, doesn't have to be perfect or complete solution, just good enough to let me do a moderately complex demo and seek funding accessibility world to build a complete environment. I appreciate the help because I believe that once this is working, it'll make a significant difference in the ability for disabled programmers to write code again as well as be able to integrate within existing development team and their naming conventions. Looking forward to responses. --- eric first draft write up of technique https://docs.google.com/document/d/1In11apApKozw_UOPAhVz0ePqns72_6652Dra34xWp4E/edit -- http://mail.python.org/mailman/listinfo/python-list
Re: simplified Python parsing question
On 7/29/2012 11:33 PM, Steven D'Aprano wrote: On Sun, 29 Jul 2012 19:21:49 -0400, Eric S. Johansson wrote: When you are sitting on or in a name, you look to the left or look to the right what would you see that would tell you that you have gone past the end of that name. For example Have you read the docs? It gives full details of the Python syntax. Yes I have. I was hoping for a different perspective because what I'm trying to do is middle out parsing. Top-down when the scanner focus moves from left to right and bottom up when the scanner focus moves from right to left. sounds kind of odd when I describe it that way but both the cursor is on the middle of a name string and I need to look to either end of that name string before can do a conversion to a symbol string, I have to look at both ends in different ways. If you've read the documentation I've provided, would it be a better example to use for describing some of the issues. Here's a very rough draft of a storyboard https://docs.google.com/presentation/d/1fuKyo9AE6i9ZdX2lucwK0v_W5Kx9M3Mezavm40wzCo8/edit the first 13-14 slides are the working content for the storyboard. the rest is mostly "memory" of things I was thinking about so if it doesn't make sense or seems wrong, don't give me grief. :-) Here's a Python parser using the pyparsing library. It's a bit old (written for Python 2.4) but it shouldn't be hard to update it to new syntax: http://pyparsing.wikispaces.com/file/view/pythonGrammarParser.py thanks for the reference. I'll take a look at it as well. -- http://mail.python.org/mailman/listinfo/python-list
Re: simplified Python parsing question
On 7/30/2012 5:25 AM, Laszlo Nagy wrote: Did you try to use pygments? http://pygments.org/docs/api/ thanks, I'll take a look. I would first tokenize the code, then divide it by statement keywords. Finally, you just need to find expression/assignment statements in the remaining sections. (Maybe there is a better way to do it.) yeah the problem is also little more complicated than simple parsing of Python code. For example, one example (from the white paper) *meat space blowback = Friends and family [well-meaning attempt] *could that be parsed by the tools you mention? I suspect not but this is what I need to generate using speech recognition because it's easily spoken. A more complex example might be something like new base = OS path-base name (old path) or if OS base exists (current path): new base name = OS path base name(current path) What's particularly cute here is that using the translation technique I can actually describe the full object method path with a minimum of speaking overhead. Python is great. :-) But the questions remain, will these tools are stuff like this? -- http://mail.python.org/mailman/listinfo/python-list
Re: simplified Python parsing question
On 7/30/2012 10:59 AM, Laszlo Nagy wrote: yeah the problem is also little more complicated than simple parsing of Python code. For example, one example (from the white paper) *meat space blowback = Friends and family [well-meaning attempt] *could that be parsed by the tools you mention? It is not valid Python code. Pygments is able to tokenize code that is not valid Python code. Because it is not parsing, it is just tokenizing. But if you put a bunch of random tokens into a file, then of course you will never be able to split that into statements. If you have been reading the papers, you would understand what I'm doing. I'm trying to take Python code with speech recognition friendly symbols and translate the symbols into a code friendly form. My conjecture is that you can change your perspective on the code and look for the edge that would normally be used to define start of a symbol, you should be able to define the name string. Another possibility is looking at the region which just contains letters numbers and spaces and outside and use that as your definition of a name string. It would probably help to verify that each word is found in a dictionary although that adds extra complexity if you are trying to increase the dictionary at the same time as the translation table. I'm beginning to think for the first generation I should just use regular expressions looking forwards and backwards and try to enumerate the possible cases. Probably, you will need to process ident/dedent tokens, identify the "level" of the satement. And then you can tell what file, class, inner class, method you are staying in. Inside one "level" or code block, you could try to divide the code into statements. I was starting in that direction so that is good confirmation Otherwise, I have no idea how a blind person could navigate in a Python source. In fact I have no idea how they use regular programs. So I'm affraid I cannot help too much with this. :-( I'm sorry, I am, and I'm trying to help, hand disabled programmers. There are more disability than blindness and after almost 20 years of encountering this shortsightedness, I do get a little cranky at times. :-) -- http://mail.python.org/mailman/listinfo/python-list
Re: simplified Python parsing question
On 7/30/2012 9:54 PM, Steven D'Aprano wrote: On Mon, 30 Jul 2012 11:40:50 -0400, Eric S. Johansson wrote: If you have been reading the papers, you would understand what I'm doing. That is the second time, at least, that you have made a comment like that. Actually, it's probably more like the forth hundred time. :-) I apologize, I was wrong and I would back up and start over again if I could Understand that most people are not going to follow links to find out whether or not they are interested in what you have to say. If you can't give a brief explanation of what you are doing in your email or news post, many people aren't going to read on. Perhaps they intend to but are too busy, or they have email access but web access is restricted, or they've already got 200 tabs open in their browser and don't want any more (I'm not exaggerating, I know people like that). accept criticism. I'm still working on an elevator pitch for this concept. I've been living with the technology and all its variations for about 10 years and it's not easy to explain to someone who is not disabled. People with working hands don't understand how isolating and, sometimes humiliating software can be. advocates like myself sometimes get a little tired of saying the same thing over and over and over again and people who are disabled just don't care. So you find yourself using shorthand because you going to be ignored anyway People use email because it is a "push" technology -- you don't have to go out and look for information, it gets pushed into your inbox. Clicking on links is a "pull" technology -- you have to make the explicit decision to click the link, open a browser, go out to the Internet and read who knows what. That requires a different frame of mind. Expect to lose some of your audience every time you require them to follow a link. Okay, this implies the need to really work on more of an elevator/summary speech. Thank you for your input. I appreciate it And *especially* so if that it a link to Google Docs, instead of an normal web page. Google Docs is, in my opinion, a nasty piece of rubbish that doesn't run on any of my browsers. As far as I'm concerned, I'd rather download a Word doc, because at least I can open that in OpenOffice or Abiword and read it. Something in Google Docs might as well be locked in a safe as far as I'm concerned. the ability for multiple people to work on the same document at the same time is really important. Can't do that with Word or Libre office. revision tracking in traditional word processors are unpleasant to work with especially if your hands are broken. It would please me greatly if you would be willing to try an experiment. live my life for a while. Sit in a chair and tell somebody what to type and where to move the mouse without moving your hands. keep your hands gripping the arms or the sides of the chair. The rule is you can't touch the keyboard you can't touch the mice, you can't point at the screen. I suspect you would have a hard time surviving half a day with these limitations. no embarrassment in that, most people wouldn't make it as far as a half a day. I've had to live with it since 1994. Not trying to brag, just pointing out the facts. I'm going to try again from a different angle in a different thread. I will take your advice to heart and I would appreciate some feedback on how well I do satisfying the issues you have described -- http://mail.python.org/mailman/listinfo/python-list
toggle name, With explanations
the wonderful responses I received from people like Lazlo, Paul, and Stephen has given me some ideas about a different approach. First, here's explanation of what I'm doing I'm developing a method which will enable hand disabled developers such as myself to create and manipulate symbols identical to those created by non-disabled developers. the input mechanism will be speech recognition maximizing the use of ordinary continuous English dictation and a minimal set of commands to activate this method. Subsequent work will produce a speech user interface for navigation code and tools such as debuggers bypassing the interference and constraints created by GUIs. The core concept is any string of a natural language words can be transformed into a symbol by storing the matchup between the natural language word string and the symbol string in a database. in other words, a dictionary which has paired keys and one key can return the other. in my original request I was thinking about parsing the environment and looking for the transition between code and symbol or natural language word string but unfortunately, that technique breaks because the characters around the region of interest may not be complete or correct code. So I thought about trying to look at the other way. If you find a string of characters that you don't look like a symbol or look like a string of natural in words, when the characters stop looking like that, then that defines the limits of the region of interest. example: s.pack(side=Tkinter.R^IGHT, fill=Tkinter.Y) the carrot marks the current position. If I was to say this point, "toggle word", I would first look to the left and the right and look forward the character string stopped looking like a symbol or a natural language word string.in this example, I would find the string "RIGHT". If I didn't find anything, I would look one more character to the left and see if there was a "." present, do the same search again this time solely to the left and I would have the string "TKinter.RIGHT". The database would have the in tree and replace it with "TK interpreter right" so I could edit the string with speech recognition. s.pack(side=TK interpreter^ right, fill=Tkinter.Y) Then using the same basic technique as I described above, I looked left and right for a series of symbols, in this case they are actually words, until I reach something that is not a symbol. The end result is used a key for the database which would return "Tkinter.RIGHT" It looks like if I'm correct, this is a much simpler way of doing what I wanted to do (extract symbols and natural language word strings). 1) can you see any holes in this logic? 2) what would you recommend for regular expressions. The reason I ask is that if you have spaces in the string, you only want want alphanumeric sequences, if you have alphanumeric plus symbol special characters, you don't want spaces. I'm not sure how strict that precondition should be. I'm going to need to think about it more. Opinions would be welcome. I think this works for almost any language too which is really important in the disabled programmer community. I appreciate your patience. Sometimes the overhead of communicating using speech recognition with tools don't work well with speech recognition such as Thunderbird makes the whole process of writing almost more difficult than it's worth. Working on tools like this is incremental progress I need to make in order to be able to bring speech recognition-based accessibility to the Python world. --- eric -- http://mail.python.org/mailman/listinfo/python-list
Re: OT: accessibility (was "Re: simplified Python parsing question")
On 7/30/2012 10:54 PM, Tim Chase wrote: On 07/30/12 21:11, Eric S. Johansson wrote: the ability for multiple people to work on the same document at the same time is really important. Can't do that with Word or Libre office. revision tracking in traditional word processors are unpleasant to work with especially if your hands are broken. If you're developing, I might recommend using text-based storage and actual revision-control software. Hosting HTML (or Restructured Text, or plain-text, or LaTeX) documents on a shared repository such as GitHub or Bitbucket provides nicely for accessible documentation as well as much more powerful revision control. But then you hit a second layer of "doesn't really work nice with speech recognition". Using a markup language can actually be more difficult than using a WYSIWYG editor. For example, with a soft word, I can do most of the basics using speech commands and I have what's called "Select-and-Say" editing capability in the buffer. Can't do that with any other editor. They are not integrated with NaturallySpeaking. A few years ago I created a small scale framework for speech recognition users (akasha). You use the domain specific market notation to be able to construct Web applications. Instead of using classic HTML models, it used things that were more appropriate to speech driven environment. unlike with HTML, which you cannot write using speech recognition and a boatload of effort, akasha was 95% speakable using out-of-the-box speech recognition. This also brings me to the concept of how the design for speech recognition use. Modifying an existing user interface or creating a new one either through a speakable data format and minimal application changes or by the application and grammar to a recognition engine and manipulating something that isn't speakable. From experience, outside of the first model works well if you are looking for relatively easy and very high marks accessibility, the second is required if you are operating within a team and need to integrate with everybody else. Unfortunately, the second technique points out just how badly designed most software is and that led me to the concept of no-UI (not unlike no SQL) which is more controversial than I want to get into right now. It would please me greatly if you would be willing to try an experiment. live my life for a while. Sit in a chair and tell somebody what to type and where to move the mouse without moving your hands. keep your hands gripping the arms or the sides of the chair. The rule is you can't touch the keyboard you can't touch the mice, you can't point at the screen. I suspect you would have a hard time surviving half a day with these limitations. no embarrassment in that, most people wouldn't make it as far as a half a day. I've tried a similar experiment and am curious on your input device. Eye-tracking/dwell-clicking? A sip/puff joystick? Of the various input methods I tried, I found that Dasher[1] was the most intuitive, had a fairly high input rate and accuracy (both initially, and in terms of correcting mistakes I'd made). It also had the ability to generate dictionaries/vocabularies that made more appropriate/weighted suggestions which might help in certain contexts (e.g. pre-load a Python grammar allowing for choosing full atoms in a given context). Just ordinary speech recognition. NaturallySpeaking. Part of my hand problem is that I no longer have good fine motor control which sucks because I used to enjoy drawing with pencils and juggling. I've tried dasher and I don't have find enough motor control to make it work very well. Sometimes I play games with my girlfriend at fly or die and the user interfaces for the various game controllers is simple enough that my hands only get in the way some of the time. Or at least that's what say when she is beating me soundly at billiards. :-) Some of the ideas you've mentioned have been thought in another contexts. The problem is that when it comes to working with code, you have two problems. Creation of code and editing code. Which do you do more? If you're like most of us, it is editing. That's why I made the toggle words feature something that would toggle both from a string name to a codename and vice versa.the future version of this and, this is where I'm going to need a lot of help from the Python community, would translate the statement in a buffer to a particular two-dimensional form and place it into a special window that NaturallySpeaking can operate on. The reason for covering it from the one-dimensional string of a statement to a two-dimensional form is to make it easier to disambiguate different features using speech. The idea isn't fully fleshed out because I want to get through this one first and actually be able to start writing code again. -- http://mail.python.org/mailman/listinfo/python-list
Re: Is duck-typing misnamed?
On 8/27/2016 7:28 PM, ROGER GRAYDON CHRISTMAN wrote: > Your response is appreciated. I just thought I'd comment a little more on > the > script: > > Woman: I'm not a witch! I'm not a witch! > > V: ehh... but you are dressed like one. > > W: They dressed me up like this! > > All: naah no we didn't... no. > > W: And this isn't my nose, it's a false one. > > (V lifts up carrot) > > V: Well? > > P1: Well we did do the nose > > V: The nose? > > P1: ...And the hat, but she is a witch! > > > They took a woman who originally, I think we might agree, was not a witch, > and they added features that were understood to be part of the protocol > for witchiness. not a witch?? https://www.youtube.com/watch?v=zrzMhU_4m-g start at 3:30 listen to what she says after they discover she weights as much as a duck. -- https://mail.python.org/mailman/listinfo/python-list
Re: [Python-ideas] Inconsistencies
On 9/11/2016 10:26 PM, Chris Angelico wrote: > No, God isn't part of the universe, any more than an author is part of > his novel. > as any fiction writer will tell you, the author is found in one or more of their characters. -- https://mail.python.org/mailman/listinfo/python-list
Re: advanced SimpleHTTPServer?
On 11/2/2016 12:15 PM, Chris Warrick wrote: > SimpleHTTPServer is meant to be used for development and testing. It > should not be used for anything remotely serious for security and > speed reasons. Given that many people are trying to use SimpleHTTPServer for "production" should teach us that the existing http servers are overly complex or at the least, not meeting needs when folks are scaling down services. for example, I've written any number of "small" webapps with a user base of 5-10. do I need apache+cgi/uwsgi+bottle? no. I need something like SimpleHTTPServer only more production ready. serious Q: what would it take to make SimpleHTTPServer more secure. It is currently fast enough. when I run bottle with it's derivative of SimpleHTTPServer, it is as fast as apache+uwsgi+bottle for 1-10 users and much much easier to set up. > Instead, you should use a real web server, such as nginx or apache. > Those will do the first two properly, and the last one could be > handled by a simple-ish PHP script. Or a full-fledged app in Django or > Flask if you feel like it. or bottle. why does everyone seem to forget bottle? simple to set up, easy to learn and useful for small to medium projects. -- https://mail.python.org/mailman/listinfo/python-list
Re: advanced SimpleHTTPServer?
On 11/2/2016 2:40 PM, Chris Warrick wrote: > Because, as the old saying goes, any sufficiently complicated Bottle > or Flask app contains an ad hoc, informally-specified, bug-ridden, > slow implementation of half of Django. (In the form of various plugins > to do databases, accounts, admin panels etc.) That's not a special attribute of bottle, flask or Django. Ad hoc, informally specified, bug ridden slow implementations abound. We focus too much on scaling up and not enough on scaling down. We (designers) also have not properly addressed configuration complexity issues. If I'm going do something once, if it cost me more than a couple of hours to figure it out, it's too expensive in general but definitely if I forget what I learned. That's why bottle/flask systems meet and need. They're not too expensive to forget what you learned. Django makes the cost of forgetting extremely expensive. I think of using Django as career rather than a toolbox. So this brings me back to my question. What is missing in SimpleHTTPServer to keep it from being secure enough? -- https://mail.python.org/mailman/listinfo/python-list
Re: Promoting your own library
On 11/11/2016 6:59 PM, Ben Finney wrote: > mirko bonasorte writes: > >> what is the most appropriate way for a developer to promote his own >> Python library? > The general answer is: Publish it with full metadata on PyPI. That's > where the Python community looks to find third-party modules, so that's > the place to put it. > > Beyond that? You'll need to know whom you want to promote *to*. Find out > where they get their information, and participate respectfully in those > forums. > I could also use some of this information. I want to publish a couple of things that I found useful. My creations tend to be single file modules or commands and what I hope to understand from your guidance is how to bundle that single file module or standalone program for publication. --- eric -- https://mail.python.org/mailman/listinfo/python-list
Re: ANN: JavaScrypthon 0.5, now with embedded evaluation of transpiled code
On 11/28/2016 2:02 PM, Amirouche Boubekki wrote: > Also, FWIW users are looking for a Javascript replacement that is real > Python, not another coffeescript. does this count? http://brython.info/ -- https://mail.python.org/mailman/listinfo/python-list
Re: Python for WEB-page !?
On 1/5/2017 7:48 PM, Michael Torrie wrote: > While Python can do that, using a web framework to process HTTP requests > and generate HTML to display in the browser, I don't believe Python is > the appropriate language for the task at hand. Most web sites that do > interactive formula calculations like you describe do it all in the > browser using Javascript. No need to have a web server do all that > heavy lifting at all. A simple html file would contain everything you need. > > Even if you want to use Python to generate the web page and process > events, you'll still have to master Javascript at some point to make the > webpages more interactive. There are a few implementations of Python that generate code that can run the browser. I'm currently using brython and its significantly easier than struggling with JavaScript. It's not perfect by any means, it has its own quirks and bugs but the developer is very responsive, the product is getting better every month and I like to see the Python community give it a bit more love -- https://mail.python.org/mailman/listinfo/python-list
Re: Learning Python (or Haskell) makes you a worse programmer
On 3/29/2016 6:05 AM, Sven R. Kunze wrote: Python = English As someone who writes English text and code using speech recognition, I can assure you that Python is not English. :-) -- https://mail.python.org/mailman/listinfo/python-list
Re: Learning Python (or Haskell) makes you a worse programmer
On 3/30/2016 6:21 AM, BartC wrote: On 30/03/2016 11:07, Sven R. Kunze wrote: On 30.03.2016 01:29, Eric S. Johansson wrote: On 3/29/2016 6:05 AM, Sven R. Kunze wrote: Python = English As someone who writes English text and code using speech recognition, I can assure you that Python is not English. :-) :D Interesting. Never thought of how Python sounds when spoken. Among other things, it becomes case insensitive... Which makes complying with Pep 8 quite the bitch. Fortunately, I have a workaround (togglename) which lets me dictate what I need to say and preserve the spoken to code for mapping for later translation. (I.e. this thing is that thing mapping). I need a co-conspirator with better hands than mine to get through the next stage which is some form of an AST smart editor that operates on larger chunks such as idioms or snippets in a speech friendly way. Ideally I'd like to see a bidirectional transform between the spoken form and a code form so that you can edit the spoken form and regenerate the code. Just one example of what I am thinking of is when you say the string name of a previously defined class instance, you get a dialogue of all available methods and string names. When you are at the point of speaking the argument list, it gives you an abstract form of the argument list that is filled in with a minimal set of speech commands. I'm too lazy to create the full description right now what if anybody wants to know more, ask and I'll fill in the blanks. It's important to remember though that using simple or accelerated methods for creating code is the easy part of the problem. It's editing existing code that is hard because you've lost a lot of the information necessary for speech user interface. This is where I think an AST based editor will come in quite handy. So far, I haven't found any. -- https://mail.python.org/mailman/listinfo/python-list
Re: Learning Python (or Haskell) makes you a worse programmer
On 3/30/2016 9:09 AM, Chris Angelico wrote: On Thu, Mar 31, 2016 at 12:06 AM, Eric S. Johansson wrote: I need a co-conspirator with better hands than mine to get through the next stage which is some form of an AST smart editor that operates on larger chunks such as idioms or snippets in a speech friendly way. Ideally I'd like to see a bidirectional transform between the spoken form and a code form so that you can edit the spoken form and regenerate the code. Sounds to me like what you want is a variant language, a speech-friendly programming language that compiles to Python. You effectively store the spoken version, and translate it (one way) to Python for execution. That would be ideal but the problem comes with working with the team. I can't expect the other members the team to learn the system. I need to be able to work according to the teams rules (coding style etc.) for proper integration into an effort. Maybe I should be looking at machine learning for identifying patterns in the code and translation back to a spoken form. It be interesting to see what people could come up with though for a speech friendly Python model. I've been wrestling with the problem so long, I probably have tons of blind spots. -- https://mail.python.org/mailman/listinfo/python-list
Best practices for single file modules Inspired by: Best Practices for Internal Package Structure
I was inspired by the thread on packaging practices discussion with bidict to ask a related question which is what are the best practices with packaging/releasing a single file Python module ? Back story: I'm always creating little bits of useful code that I want to reuse (for example, recursive expansion template module). It seems like the overhead of setting up a module is a bit high for a single file module but maybe this modern nation I'm not aware of or template based techniques that would lower the setup overhead. -- https://mail.python.org/mailman/listinfo/python-list
Re: Python on Windows with linux environment
On 6/2/2016 12:38 PM, Wildman via Python-list wrote: > On Thu, 02 Jun 2016 04:22:45 -0700, Muhammad Ali wrote: > >> Hi, >> >> I use windows regularly, however, I use linux for only my research work at >> supercomputer. In my research field (materials science) most of the scripts >> are being written in python with linux based system. Could I installed such >> linux based python on my window 7? So that I can use those linux based >> scripts written in python and I can also write my own scripts/code without >> entirely changing my operating system from windows to linux. >> >> Looking for your valuable suggestions. >> >> Thank you. > There is coLinux and andLinux. those are both mostly dead (it seems). I went the cygwin route. still sucks but a bit less than straight windows. -- https://mail.python.org/mailman/listinfo/python-list
Re: Python on Windows with linux environment
On 6/2/2016 2:03 PM, Joel Goldstick wrote: > Although the OP is using Windows 7, according to recent articles, > Ubuntu is teaming with MS for Windows 10 to include a bash shell, > presumably with the package management of Ubuntu (debian), with pip > goodness and virtualenv and virtualenvwrapper. That route should make > W10 and linux (ubuntu) nearly identical environments to deal with had forgotten about that. it should be released end of july and I am looking forward to the update! in the meantime, I'm suffering with cygwin :-) -- https://mail.python.org/mailman/listinfo/python-list
Re: Python on Windows with linux environment
On 6/3/2016 12:02 AM, Muhammad Ali wrote: > On Friday, June 3, 2016 at 6:27:50 AM UTC+8, Eric S. Johansson wrote: >> On 6/2/2016 2:03 PM, Joel Goldstick wrote: >>> Although the OP is using Windows 7, according to recent articles, >>> Ubuntu is teaming with MS for Windows 10 to include a bash shell, >>> presumably with the package management of Ubuntu (debian), with pip >>> goodness and virtualenv and virtualenvwrapper. That route should make >>> W10 and linux (ubuntu) nearly identical environments to deal with >> had forgotten about that. it should be released end of july and I am >> looking forward to the update! in the meantime, I'm suffering with >> cygwin :-) > > Please send me the link through which I can get regular updates about this > new release. switch to windows 10 and wait. MS will cram an update into your machine :-) -- https://mail.python.org/mailman/listinfo/python-list
a ConfigParser wtf moment
I'm not sure if this is a real problem or if I have been staring at code too long. given this code #!/usr/bin/python from ConfigParser import * configuration_file = "test.conf" substitution = {"xyzzy":"maze"} configuration = SafeConfigParser() configuration.readfp(file(configuration_file)) list = configuration.items("core") print list list = configuration.items("core",0, substitution) print list --- and this configuration file --- [core] xyzzy=little bird dwarf = greasy smoke %(xyzzy)s plugh why do I get the following results? - trial backup # python test.py [('dwarf', 'greasy smoke little bird plugh'), ('xyzzy', 'little bird')] [('dwarf', 'greasy smoke maze plugh'), ('xyzzy', 'maze')] trial backup # - if you're having a hard time seeing it, before the substitution, xyzzy is set to the value in the configuration file, afterwards, it is set to the value of the substitution in the code. It seems to me that substitutions should not affect any configuration file symbols of the same name. anyway to fix this problem without python diving? ---eric -- http://mail.python.org/mailman/listinfo/python-list
Re: a ConfigParser wtf moment
[EMAIL PROTECTED] wrote: To avoid this, you need to write something like: . list = [] . for key in configuration.options("core"): . list.append((key,configuration.get("core",substitution)) . print list This cause me problems for a different reason, ie., that user vars keys appear in what items() returns. I avoid using items() for this reason. it turns out, I originally discovered this problem through the get with substitutions. It's too late to muck with it now but if you are really interested I will generate a test case showing the failure or else prove I was hallucinating. My current workaround is to look for a %( in every value returned and if so do a string substitution. value = base.get(section,item, 1) if value.find("%(") != -1: value = value% self.interpolation_symbols yes, it is as ugly as a roadkill toad but it gets the job done. I've spent away too much time on this problem for this particular project. I think we all know the feeling. ---eric -- http://mail.python.org/mailman/listinfo/python-list
Re: how to find site-packages path
Michael Hoffman wrote: Philippe C. Martin wrote: I am using my own install script for my software and am looking for a flawless way to figure out where python, and more specifically site-packages is installed. The flawless way would be to use distutils. In fact you shouldn't even need your own install script--it should do most of the work for you. can distutils install in any directory? for example, an application which has its own modules should be completely isolated from the general Python module namespace. how would you make distutils install in a completely separate directory hierarchy and not touch any of the site-packages directories or files? it looked like that was impossible from the documentation which is why I wrote my own installer. ---eric -- http://mail.python.org/mailman/listinfo/python-list
simultaneous multiple requests to very simple database
I have an application where I need a very simple database, effectively a very large dictionary. The very large dictionary must be accessed from multiple processes simultaneously. I need to be able to lock records within the very large dictionary when records are written to. Estimated number of records will be in the ballpark of 50,000 to 100,000 in his early phase and 10 times that in the future. Each record will run about 100 to 150 bytes. speed is not a huge concern although I must complete processing in less than 90 seconds. The longer the delay however the greater number of processes must be running parallel in order to keep the throughput up. It's the usual trade-off we have all come to know and love. it is not necessary for the dictionary to persist beyond the life of the parent process although I have another project coming up in which this would be a good idea. at this point, I know they will be some kind souls suggesting various SQL solutions. While I appreciate the idea, unfortunately I do not have time to puzzle out yet another component. Someday I will figure it out because I really liked what I see with SQL lite but unfortunately, today is not that day (unless they will give me their work, home and cell phone numbers so I can call when I am stuck. ;-) So the solutions that come to mind are some form of dictionary in shared memory with locking semaphore scoreboard or a multithreaded process containing a single database (Python native dictionary, metakit, gdbm??) and have all of my processes speak to it using xmlrpc which leaves me with the question of how to make a multithreaded server using stock xmlrpc. so feedback and pointers to information would be most welcome. I'm still exploring the idea so I am open to any and all suggestions (except maybe SQL :-) ---eric -- http://mail.python.org/mailman/listinfo/python-list
Re: simultaneous multiple requests to very simple database
Robert Brewer wrote: Eric S. Johansson wrote: I have an application where I need a very simple database, effectively a very large dictionary. The very large dictionary must be accessed from multiple processes simultaneously. I need to be able to lock records within the very large dictionary when records are written to. Just to clarify, you want shared-read until a write, at which point you want to lock just the item being written? Or would page or table locking be acceptable at that point? just the item/record. I'm doing arrival rate calculations. each record contains a set of arrival times and I am rewriting the record every time a new entry arrives. complete page or table locking will work in the sense that it will prevent collisions but it will have an increasing impact as load and simultaneous table but not record accesses increase. ---eric -- http://mail.python.org/mailman/listinfo/python-list
anydbm biasing
I have a preference for gdbm when building DBM based dictionaries but have found I cannot count on it being there all the time. Therefore, I have created this little tidbit which you call before opening your anydbm database to bias the preference towards gdbm instead of dbhash: # bias DBM towards gdbm if at all possible. def bias_anydbm(): """bias anydbm to gdbm""" try: _mod = __import__("gdbm") except ImportError: pass else: # and other words, if you can import gdbm, make it the default anydbm._defaultmod = _mod usage: bias_anydbm() open_DBM = anydbm.open(DBM_path, 'c') if you have gdbm enabled, it will use that otherwise it will default to the search list in anydbm. obviously, this can be used to bias anydbm to meet your own preferences ---eric -- http://mail.python.org/mailman/listinfo/python-list
Re: simultaneous multiple requests to very simple database
Thomas Bartkus wrote: "Eric S. Johansson" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] at this point, I know they will be some kind souls suggesting various SQL solutions. While I appreciate the idea, unfortunately I do not have time to puzzle out yet another component. Someday I will figure it out because I really liked what I see with SQL lite but unfortunately, today is not that day (unless they will give me their work, home and cell phone numbers so I can call when I am stuck. ;-) Forgive me if this reply sounds a bit glib. But I do mean it without malice. understood and taken in that spirit. Do you seriously expect to write your own (database) solution and that this will save you time and effort over learning an existing (SQL) solution? Because - If you are seeking to "save time" on "puzzles", you are certainly going about it the wrong way. one thing I learned a long time ago was to respect the nagging voice in the back of my head that says "there is something wrong". Right now with databases, that voice is not nagging but screaming. So I made my query to try and prove that intuition wrong. So far, that has not happened. When I look at databases, I see a bunch of very good solutions that are either overly complex or heavyweight on one hand and very nice and simple but unable to deal with concurrency on the other. two sets of point solutions that try to stretch themselves and the developers to fit other application contexts. 99.9 percent of what I do (and I suspect this could be true for others) could be satisfied by a slightly enhanced super dictionary with a record level locking. but, the database world does not fit this model. It has a great deal more complication then what is frequently necessary. If I ever find the time, I will try to build such a beast probably around Metakit. The only reason for reluctance is that I have spent too many hours tracking down concurrency problems at the OS level way to many years ago and so I do not create multithreaded applications lightly. so in conclusion, my only reason for querying was to see if I was missing a solution. So far, I have not found any work using because they add orders of magnitude more complexity than simple dbm with file locking. Obviously, the simple solution has horrible performance right now I need simplicity implementation. thanks for your commentary. ---eric -- http://mail.python.org/mailman/listinfo/python-list
Re: simultaneous multiple requests to very simple database
Ricardo Bugalho wrote: On Tue, 18 Jan 2005 17:33:26 -0500, Eric S. Johansson wrote: When I look at databases, I see a bunch of very good solutions that are either overly complex or heavyweight on one hand and very nice and simple but unable to deal with concurrency on the other. two sets of point solutions that try to stretch themselves and the developers to fit other application contexts. Have you considerded SQLite/pySQLite ? yep and apparently it won't work http://www.sqlite.org/faq.html#q7 if I had record level locking, the code would do a very common pattern like: if record present: Lock record modify record release lock else: create record atomically (actual method TBB) if I read their opinion correctly, the SQL lite folks are wrong in that only the applications need massive concurrency. Small applications need significant to massive concurrency for very tiny windows on very little data. but I do appreciate the pointer. -- http://mail.python.org/mailman/listinfo/python-list
Re: simultaneous multiple requests to very simple database
Thomas Bartkus wrote: When you write that "super dictionary", be sure to post code! I could use one of those myself. hmmm it looks like you have just flung down the gauntlet of "put up or quityerwhinging". I need to get the crude implementation done first but I think I can do it if I can find a good XMLRPC multithreading framework. ---eric -- http://mail.python.org/mailman/listinfo/python-list
Re: Berkely DB – many writers, many readers
Andy Leszczynski wrote: > > I need to now option I open the Berkley DB (both db and env) to have > configuration for multiple writers and multiple readers. Via multiple > processes and multiple threads. No trx needed. the simple answer is you can't. bdbm is probably single writer multiple reader. I believe if you use of the the most recent sleepy cat database, you have support for multiple readers and writers in any context. when I did this, I stuck my gdbm database into a multithreaded stand-alone process. I used XML RPC for access and used a per key locking mechanism internal to the data storage and retrieval process. This locking mechanism set appropriate locks so that a writer for specific key would wait for all readers of that key to finish, and block all subsequent readers until it was done. so far is working pretty well but I haven't tried it in a high load situation. ---eric -- http://mail.python.org/mailman/listinfo/python-list
Re: asynchat and threading
Anthony Baxter wrote: twisted is too large to go into the python core as is - in addition, there's a mismatch between Python's release cycle speed and twisted's release cycle speed (although the current delayed-until-who-knows-when Twisted 2.0 might be a harbinger of twisted slowing down to Python's speed ) It's possible that in the future a small core of twisted could end up in the stdlib - this topic's come up a couple of times on the twisted list (most recently, a couple of months ago). I wonder if the asyncore docs couldn't grow a 'See also' that points at twisted, though... this points to an important issue that should be addressed at some point which is the ability to quickly and easily, on the level of rpm or apt-get, import external frameworks. I have a body of code which counts on smtpd.py and pop3d.py. I have modified both and just created new versions to sit within my application. Easy integration. If I was to count on twisted, I would have another fetch fest collecting all the pieces as well as increasing the complexity of building my application. If I could simply do: py-get twisted and have all of the dependencies resolved, it would be wonderful. as a prototype, I would suggest wrapping apt-get with a python envelope which automatically invokes apt-get with a python specific configuration file for .pydeb files as well as a private repository and database etc.. Since apt-get exists for almost every version of Linux and should be portable to other platforms, this distribution method should be relatively distribution portable. One can also handle upgrades of the core image of Python and ancillary packages as well by leaving a breadcrumb file indicating which packaging system is native and the package currently installed. <<- idea needs work yea? nay? ---eric -- http://mail.python.org/mailman/listinfo/python-list
Re: asynchat and threading
Jp Calderone wrote: Why not use apt-get? well, I am recommending using apt-get but within entirely different and separate namespace for modules. But on second thought,, it might not be necessary to separate the namespace. If you just need to add the repository for Python modules to the apt-get configuration files, it might just work. hmmm. the trick would be making modules that were multiplatform/distribution aware. ---eric -- http://mail.python.org/mailman/listinfo/python-list
writing to mailboxes
I've been searching around for the equivalent to the mailbox module except with the capability of writing messages as well as reading. If it makes it easier, I only need to write to maildir mailboxes. I found a reference to http://pythonms.sf.net/ Python mail system) but it seems to have vanished. Any suggestions? ---eric -- http://mail.python.org/mailman/listinfo/python-list
extracting string.Template substitution placeholders
As part of speech recognition accessibility tools that I'm building, I'm using string.Template. In order to construct on-the-fly grammar, I need to know all of the identifiers before the template is filled in. what is the best way to do this? can string.Template handle recursive expansion i.e. an identifier contains a template. Thanks --- eric -- https://mail.python.org/mailman/listinfo/python-list
Re: extracting string.Template substitution placeholders
On 1/13/2014 2:24 AM, Steven D'Aprano wrote: On Sun, 12 Jan 2014 10:08:31 -0500, Eric S. Johansson wrote: Now just walk the template for $ signs. Watch out for $$ which escapes the dollar sign. Here's a baby parser: found a different way import string cmplxstr="""a simple $string a longer $string a $last line""" nst=string.Template(cmplxstr) identifiers = {} while True: try: result = nst.substitute(identifiers) except KeyError, error: print error identifiers[error[0]] = "x" else: break print "loop done" -- at the end I only care about the keys in identifier which I fill in after user interaction. -- https://mail.python.org/mailman/listinfo/python-list
Re: What is the most pythonic way to build up large strings?
On 2/8/2014 3:35 AM, Rustom Mody wrote: On Saturday, February 8, 2014 1:11:53 PM UTC+5:30, cstru...@gmail.com wrote: I am writing a couple of class methods to build up several lines of html. Some of the lines are conditional and most need variables inserted in them. Searching the web has given me a few ideas. Each has its pro's and cons. For creating html the method of choice is a template engine -- cheetah, mako and a dozen others You can of course roll your own (poor mans version) template engine For that look up 1. triple quoted strings 2. format operator as so happens, I'm traveling down a similar path myself. My goal is to use it to generate code for disabled, speech recognition using programmers (like myself). I believe my best route is using a modified version of string.Template but I wonder if my biases keep me from seeing a good alternative. I believe the following characteristics are essential: Easy to speak output generated with the right indentation recursive expansion can list substitution names Here's an example of use. The current model for visual output is a split screen simulated as text between two long lines of : Saying: add method --- in the GUI/editor - method_name??undefined - def method_name(): - Saying: add three arguments --- in the GUI/editor - method_name??undefined argument_1??undefined argument_2??undefined argument_3??undefined - def method_name(argument_1, argument_2, argument_3): - Saying: fix undefined --- in the GUI/editor - method_name??^ argument_1??undefined argument_2??undefined argument_3??undefined - def method_name(argument_1, argument_2, argument_3): - Saying some method name --- in the GUI/editor - method_name??some method name argument_1??undefined argument_2??undefined argument_3??undefined - def some method name(argument_1, argument_2, argument_3): - You repeat the process saying "fix undefined"until all of the substitution names were filled in and the expanded template in the lower window was correct. The conversion from string names such as "some method argument" to codenames (SmMnm) happens in a different part of the process. The problem am working on now is if I change something in the list of substitution names (upper window) how does that affect the code generated and shown in the lower window? The vast majority of the time, deleting a substitution name resets it to undefined. But deleting argument is special. At the moment, I'm going with explicit alteration of an argument list rather than inferring the argument list from the arguments in the substitution name window. I'm reasonably sure that templates, some sort, are the way to go for reducing vocal load. What I'm still wrestling with is the kind of overhead I impose on the programmer and that, in turn, defines the kind of templates I need for programming by speech. Solving this problem has made me curse one feature of Python which is it's type system. Something, more static, would make things much easier because the type information could be used to predict what will be said next thereby reducing the number of hacks, such as templates, necessary to write code. However, given that one can write Python reasonably well using ordinary speech recognition, I can almost live with its type system. :-) but, if somebody knows a way to make an empirical determination of type, I wouldn't turn away the help -- https://mail.python.org/mailman/listinfo/python-list
need some guidance on Python syntax smart editor for use with speech recognition
Some of you will recognize me as someone who pops up occasionally asking questions as I grope my way to a usable speech driven programming environment. My last set of experiments with a technique called togglename and speech driven template notation hit a pretty nasty wall of usability because of a fundamental incompatibility between GUIs and speech recognition and the lack of support Nuance gives to disabled users in general. Before anybody suggests it, yes I know about that guy who gave a talk at a python convention and uses what we call the burp, belch, and fart school of speech recognition engine abuse. yes that is actually an affectionate description. :-) what he did is impressive but it's not where I'm going I think the techniques I was experimenting with are good ones because they do make it easier to speak code. the problem comes about because of the irreversibility of the transformation making editing code as difficult as it was before. A little background. Today, Python is an amazingly speech recognition friendly programming language (especially if you ignore pep-8). Using simple macros, you can pretty much noodle along and write code relatively easily. A few more specialized pieces and it's almost easy to rip, shred, and tear code into new shapes as you realize you went down the wrong path but still have lots of good idioms. However, as easy as it is to noodle along, creating code I find myself somewhere around 0.8 as effective as I was with my hands and in editing code, I'm around 0.5 or less. My goal is to make speech driven programming at least on a parity with someone who has useful hands and hopefully 3 to 5 times faster. a few years ago, a disabled friend of mine pointed out that the hard problem was not the creation of code but the editing of code. I took his observations to heart and have been working on trying to create a speech friendly environment that that can transform from the speech notation to the code notation and back again and still remain functionally identical. I have some ideas but I need some outside perspective from people who know Python better than I do. The core of the idea is an editor which can present code in two forms. The first form is what you guys all know in love but is horrible to speak. The second form is something that is easy to speak, and as I said above, functionally identical to the code form. An ideal solution would give me the ability to toggle back and forth between these two representations. An experiment would be to play with is displaying both representations at the same time so you can see what you speak in near real-time. The speech environment lends itself to speaking the broad intent and then answering questions to fill in the detail to create something concrete. For example, in one of my prototypes (shown below), I state that I want a class. Then I fill a detail like an initialization function, inheriting from a parent, copying in all the arguments etc. and I end up with a full class definition much more quickly than I could even type it with good hands. This is what I meant above by 3 to 5 times faster than hand generated code. But with every experimental success, there is usually more than one problem. In this case is that I lose all the meta-information when I create the instance of the intent plus detail. I can't go back to that abstract form. The obvious answer is saving that meta-information in conjunction with the code but when working in a team environment, that information is going to drive you handies up the wall because it's going to visually overwhelm the actual code. Serving the meta-information separately will mean it's even harder to recover a speech friendly version of the code after it's been touched. Another thought experiment has been with always generating syntactically correct code and basing various code generation and navigation constructs around that. So the questions I have right now are, or what's a good open editor ( preferably multiplatform) that actually decomposes Python code into fundamental components such as class, expression, etc. and, lets you operate on those components? this is in contrast to editors such as Emacs which give you some fundamental pieces you can operate on but it's really character oriented and all of the syntax smartness not really available for coupling to speech recognition environment. it would be great if it was in Python so I don't have to learn yet another fricking language. What would be the best way to store meta-information necessary to re-create the speech friendly presentation of code? I don't know if this is possible but I would like to be able to let handy programmers make changes that will be propagated automatically into the speech friendly code presentation without forcing them to learn the new notation. An example of this is the definition of the class. In my world, a class definition
Re: need some guidance on Python syntax smart editor for use with speech recognition
On 1/5/2015 3:12 AM, Chris Angelico wrote: On Mon, Jan 5, 2015 at 6:43 PM, Eric S. Johansson wrote: The obvious answer is saving that meta-information in conjunction with the code but when working in a team environment, that information is going to drive you handies up the wall because it's going to visually overwhelm the actual code. Serving the meta-information separately will mean it's even harder to recover a speech friendly version of the code after it's been touched. This, I think, is going to be your hardest problem to solve. Once someone edits your code using a conventional set of tools, any saved meta-information will be out of date, and that's a critical failure; ergo you can't save anything, and have to deduce it all from the code. Exactly. That's one of the reasons why I was heading down the path of embedded meta-metadata. It might be acceptable if I could devise rules for hiding the metadata but even with that, the reversal is still a bit of a challenge.. So your only option, as I see it, is to devise some kind of 100% reversible transliteration format. With the right metadata, you have that reversibility. I think what makes it easier and harder is that when you write code using speech, you tend to use idioms (a.k.a. templates). My gut sense tells me that I should be able to recognize the structure of an idiom for going back from the code form to the speakable form. the metadata should help this process. In the example I gave of class, the actual template generating code has a bunch of conditionals to add or delete subcomponents of the template. the template tool I use is something I developed myself which is a speakable template form, can do recursive expansion but has no conditionals in it (doing so reduces speak ability). I think a form of pattern matching or shape recognition would be core to creating the code to speakable form translation but I'm feeling a bit stumped because I don't know where to find how other people have solved this kind of problem. I should clarify that by shape recognition, I don't mean a geometric or image-based shape. it's more of an abstraction I used in my own mental models of how code is constructed. for what it's worth, what I just described is one of the things that makes programming by speech so difficult. We all have different mental models of how code works. I see code in three dimensions varying in time. I know not everybody does. :-) One of the side effects of this visualization of code is that it lets me identify potential idioms. Some idioms are task transient, others are more general. If there's some way to recognize the pattern of code that is in an idiom and be able to preserve the variations within the idiom then I think we are on the right path. Interestingly, this is sometimes needed between human languages. Romanization of (say) Korean text involves representing the sounds of the syllables in some kind of Latin script. If those transliterations are perfectly reversible, you can manipulate the Korean text using a US-English keyboard [1], while still producing correct Korean output. It ought, in theory at least, to be possible to craft a reversible transliteration between Python code and a more efficient speakable form. You might have to place some restrictions on the Python code (for instance, strict formatting rules, to avoid having spurious edits when you use speech mode), and maybe you'd need a "fall-back" spoken form that spells out the exact code, in case someone's done something weird. But this would be something where you'd be better able to judge than I am. it'll never be 100% speech driven. There will always be a time when you have to use your hands. The goal is to minimize that time. I should also point out that going from A -> B -> A' is not going to result in A = A' at least not at a character for character level. however, given a set of inputs, you will get identical results on outputs when using A and A'. Yes, this will make differences in revision control hard to track unless the check in process performs a A -> B -> A' transformation and only checks in A' So maybe now the question has changed to how does one specify an idiom such that one can extract the arguments defining that idiom instance from existing source code. --- eric -- https://mail.python.org/mailman/listinfo/python-list
Re: need some guidance on Python syntax smart editor for use with speech recognition
On 1/5/2015 7:24 AM, Chris Angelico wrote: On Mon, Jan 5, 2015 at 8:34 PM, Jonas Wielicki wrote: As a first iteration, I would try with any editor written in Python. Are you familiar with the ast[1] module? It could be worth trying to use this module and perform some kind of pattern matching on the results to recover the information. An AST parse throws away a lot of information. You can't easily reconstruct the original code from that; at best, you can decompile the AST back into functionally-equivalent source code, but it's not something you want to do as part of editing code. Chris is right. I looked at this and came up with the same conclusion. Here's a use case that I haven't talked about yet but is part of the problem of speech driven programming. I have a chunk of code that I created that is exactly right but it's in the wrong place or wrong method or even just the wrong environment. I need to capture it and then move it to the right place. At first glance, this would look like a simple cut-and-paste and, sometimes it is but more often it's not. Let's take the example of a simple file generator. Opening the file, iterating over the input until the input data transformation process runs out of data. This is a real common pattern and what changes are certain elements of the code, variables, strings whatever but also the indentation. So putting the old chunk of code into the new place requires transformation that most of you guys do by hand without thinking twice. Me it's, #()@!$, and I use a whole bunch of kill words to strip out the old data and put in the new. Imagine being able to rip out a piece of code, identify the substitution points and the indentation adjustment levels and then being able to put in that piece of code in other places and just fill in the blanks as a part of the insertion dialogue. Now this gets us to the same point I was first talking about which is the ability to identify the idiom and code to operate on it as an idiom. some of the stuff I've seen with snippets is partly there, again it is a one-way transform. It seems to me that those of us with hands and those of us with broken hands could use this same functionality given the right supportive user interface. Now I've been living with this kind of idea for a while and I realize that may not make sense in this abstract written description. What do I need to fill in? However, back when I was doing my PEP 463 research, someone suggested looking into the 2to3 parser. I regretfully admit that I have yet to actually do so, but it ought in theory allow source-level transformations with a measure of intelligence. It's not a ready-made solution by any means, but it could be a useful tool. [2] Good idea. Hope this helps. I find that topic pretty interesting. Is there anything I can follow to see progress on this? Likewise! ChrisA Is there any problem with keeping the conversation going here or would you prefer some other way of talking about it? I've been hesitant to put my work up on github because it's flailing about with also the bloody loose ends because I'm trying to solve up number of problems all at the same time. The problem first being a framework where I can add speech driven UI elements to an editor so I can start experimenting with a bunch of these pieces. Another way you can help is be my hands. sometimes I just run out of hand time and it takes a while for me build up enough energy so I can spend the day working for money and a day working on this. --- eric -- https://mail.python.org/mailman/listinfo/python-list
Re: Accessible tools
On 2/19/2015 10:33 AM, Bryan Duarte wrote: Thank you jwi, and Jacob, I took a look at that posting and it seems pretty unique. I am not much interested in the speech driven development, but I am very interested in developing an accessible IDE. Well you should be because it looks like an aural interface (uses speech instead of keyboards) uses the same kinds of data to present to either a text to speech or speech recognition driven environment. A professor and I have been throwing around the idea of developing a completely text based IDE. There are a lot of reasons this could be beneficial to a blind developer and maybe even some sighted developers who are comfortable in the terminal. The idea would be really just to provide a way of easily navigating blocks of code using some kind of tabular formatting, and being able to collapse blocks of code and hearing from a high level information about the code within. All tools and features would obviously be spoken or output in some kind of audio manor. I've been working with another professor working on some of these issues as well. His focus has been mostly blind young adults in India. come up with some pretty cool concepts that looks very usable. The challenge now is to make them work and, quite frankly monetize the effort to pay for the development. Again, this shows the similarities in functionality used by both speech recognition and text-to-speech. All I care about is text and what I can say. We're now working with constructs such as with-open, argument by number, plaintext symbol names (with bidirectional transform to and from code form), guided construct generation for things like classes, methods, comprehensions etc. All of these things would be useful to handed programmers as well as a way of accelerating co-creation and editing. Unfortunately, like with disabled people stove piping text-to-speech versus speech recognition, handed developers stovepipe keyboard interfaces and don't really think about what they are trying to do, only how they are doing it. Yes yes, it's a broadbrush that you can probably slap me with. :-) Oh and before I forget does anyone know how to contact Eric who was developing that accessible speech driven IDE? Thanks Well, you could try looking in a mirror and speaking my name three times at midnight But you would get better results if you used my non-mailing list email address. e...@eggo.org. --- eric -- https://mail.python.org/mailman/listinfo/python-list
Re: 'Lite' Databases (Re: sqlite3 and dates)
On 02/21/2015 01:22 AM, Ned Deily wrote: SQLite is one of the most widely-used, best-documented, best-tested, and well-respected software packages in the world. yes but is still sql. there are a couple of small scale not-sql databases that look interesting. problem with them is that the creator seem to subscribe to the build-and-toss-into-the-wild school of development. http://buzhug.sourceforge.net/ http://www.pydblite.net/en/index.html both are useful, both could use multi-writer support, and both need some love from the python world. --- eric -- https://mail.python.org/mailman/listinfo/python-list
Re: meta language to define forms
On 3/27/2014 4:56 PM, Sells, Fred wrote: I'm trying to use python classes and members to define complex data entry forms as a meta language The idea is to use a nice clean syntax like Python to define form content, then render it as HTML but only as a review tool for users, The actual rendering would go into a database to let a vendor's tool generate the form in a totally non-standard syntax that's really clunky. I've run into a similar problem when building a framework for programming by speech and web application development. Although, my goals were different. I want to something you can create with speech recognition without too much of a vocal load or requiring extensive/specialized editor changes. One could say I was trying to make it possible to develop web apps in Microsoft Word. :-) The first attempt was a bracketed notation that was in effect a very high level domain specific notation. The next attempt is trying to eliminate the use of bracketing notation to specify scope and said use indentation. Like you, the environment consists of little bits of Python that takes what you want in the form/user interface and generates the HTML and JavaScript for presentation in action. To use your example, my notation would look something like this : Form uses section_title; Enter Patient Vital Signs uses number_question; 3, Enter pulse rate : drop_down_list uses title; Enter current status uses choices; 1, alive and kicking uses choices; 2, comatose uses choices; 3, there's another dead Bishop on the landing The: names refer to the methods that generate the code using the arguments provided by the statements within the: name definition. as refine what is your trying to do, you can make the: names more and more meta-and less and less implementation details. For example, one of the experiences that told me the bracketed notation was not going to fly was when I created a storefront for telescope shop. I created notation that expressed the work of the store not the display of the store information. Obviously the output of the notation was the display data but it operated in a way that the storekeeper understood and could take care of himself which was impossible with ordinary HTML and completely impossible if you added something like bootstrap. And before somebody kicks up a fuss About the notation, let me say that this was aimed at disabled developers who cannot type anymore or who want to listen because they cannot see. What I have created is far more productive and speakable than any of the other systems out there. --- eric -- https://mail.python.org/mailman/listinfo/python-list
converting old project to Python 3 was: Re: Why Python 3?
On 4/19/2014 12:04 AM, Ryan Hiebert wrote: If you are starting a new project, I'd highly encourage you to use Python 3. It is a stable, well supported, and beautiful language, and gives you the full power of the innovation that is current in the Python world. Python 2 is still well supported (for a while to come), but you won't have the same access to new features and ideas that you would on Python 3. The only reason that I'd still be on Python 2 is if I absolutely had to use a library that for some reason is not yet working on Python 3. Even then, I'd work hard to try and write it in Python 3 style Python 2, because I'd want to be on Python 3 as soon as possible. The Python extensions to NaturallySpeaking are combination of C++ for a COM interface and Python for grammar management. http://qh.antenna.nl/unimacro/implementation_and_acceptance_of_natlink.pdf How hard is it to convert from C++ extensions for 2.x to 3.x? are there any tools to help with the process? Thanks for any insights. --- eric -- https://mail.python.org/mailman/listinfo/python-list
parsley parsing question
how do you parse multi line text with parsley? here is a work in progress and I'm trying to figure out why I need to split the text and process per line vrs all at one go. thanks for any help. --- eric Here's the whole body of code --- import parsley # # grammar to parse # # uses # template # returns(|file: |) # remembers # alt form # template[:] # test targets def do_uses(a,b): print "do_uses %s - %s -"% (a,b) def do_returns(a): print "do_returns %s"% (a) def do_template(a): print "do_templates %s"% (a) # parsleyfied grammar TF_grammar = r""" kwToken = (letter|digit|'_')* uses_statement = 'uses' ws kwToken:kwT ':' anything*:roL '\n'{0,1} -> do_uses ("".join(kwT), "".join(roL)) returns_statement = 'returns' ws kwToken:kwT '\n'{0,1} -> do_returns("".join(kwT)) template_statement = 'template' ws kwToken:kwT '\n'{0,1} -> do_template("".join(kwT)) bow = (uses_statement | returns_statement | template_statement) ws """ # action_table = { "do_uses": do_uses, "do_returns": do_returns, "do_template": do_template, } # alt path: split lines and parse them one at time def run_bot(body_of_text): """break up the body of text""" for i in body_of_text.split("\n"): if len(i) != 0: # why is this test needed? x = parsley.makeGrammar(TF_grammar,action_table) x(i).bow() xxx="""uses foo: this is some text returns xyzzy template templatename """ # multi-line solution x = parsley.makeGrammar(TF_grammar,action_table) x(xxx).bow() test line-at-a-time solution run_bot(xxx) -- bad result (multi-line) is --- $ python parsleytest.py do_uses foo - this is some text returns xyzzy template templatename - good result should be --- $ python parsleytest.py do_uses foo this is some text do_returns xyzzy do_template template templatename -- https://mail.python.org/mailman/listinfo/python-list
Re: OT: This Swift thing
On 6/3/2014 5:49 PM, Mark H Harris wrote: I have been engaged in a minor flame debate (locally) over block delimiters (or lack thereof) which I'm loosing. Locally, people hate python's indentation block delimiting, and wish python would adopt curly braces. I do not agree, of course; however, I am noticing when new languages come out they either use END (as in Julia) or they propagate the curly braces paradigm as in C. The issue locally is trying to pass code snippets around the net informally is a problem with indentation. My reply is, well, don't do that. For what I see as a freedom issue, folks want to format their white space (style) their way and don't want to be forced into an indentation paradigm that is rigid (or no so much!). the only problem I have with indentation defining blocks is that it's hard to cut and paste code and make it fit the right block level automatically. Too many times of made the mistake of one or two lines off by one or two levels of indentation and somehow the code doesn't work as I thought it would :-) It's also making it difficult to generate code automatically. On the other hand, curly braces are royal pain to dictate or navigate around when programming with speech recognition. --- eric -- https://mail.python.org/mailman/listinfo/python-list
Re: OT: This Swift thing
On 6/3/2014 7:29 PM, Chris Angelico wrote: On Wed, Jun 4, 2014 at 9:22 AM, Eric S. Johansson wrote: On the other hand, curly braces are royal pain to dictate or navigate around when programming with speech recognition. I've never done that, in any language, but if I had to guess, I'd say that both braces and indentation are harder to work with than a REXX style where *everything* is words. :) The model I am working with now, and it requires a very smart editor, is the jump down - jump up approach or the combination of mouse and voice where you move the cursor to where you want to go and say "go here". Yes, sometimes it's easier to move a mouse that is to click it and both are easier than dragging. -- https://mail.python.org/mailman/listinfo/python-list
Re: Newbie: static typing?
On Tue, 06 Aug 2013 09:27:10 -0400, Burak Arslan wrote: First, let's get over the fact that, with dynamic typing, code fails at runtime. Irrespective of language, you just shouldn't ship untested code, so I say that's not an argument against dynamic typing. It's not so much shipping untested code as not having or unable to test all the pathways in the code shipped. I ran into this problem with a server I built. I ended up solving the problem by building a testing scaffolding that let me control all inputs. It would've been much easier with static typing to make sure all the pieces lined up. The other technique I've used is a properly set up exception handling environment. Do it right and you can log all of the errors so that you have useful information. Part of "doing it right" includes a system that tells you when exceptions happened right away so the server doesn't run for days or more failing at random but nobody notices because your exceptions keep the system for failing completely. I guess this is a long way of saying instrument your software so that it can be tested and or give you enough information about the internal state. This is sort of like building a specialized integrated circuit. You need to design it so it can be tested/observed after it's been embedded in epoxy and not just count on being able to probe the wafer in the lab. -- http://mail.python.org/mailman/listinfo/python-list
Re: Debugging decorator
On 10/25/2013 7:55 PM, Yaşar Arabacı wrote: Hi people, I wrote this decorator: https://gist.github.com/yasar11732/7163528 wow, this looks really powerful. I would like to add the ability to associate a tag or set of tags with the decorator so that the debug output only happens when there is a matching tag in some global or environmental variable. -- https://mail.python.org/mailman/listinfo/python-list
need help with an accessibility prototype
2 needs. first is determining if NaturallySpeaking injects keycodes or ascii char into the windows input queue. second is building a test widget to capture and display text. I think I can solve both of these by building a simple text widget (tkinter? qt? ??) to capture keycodes. problem, is in yrs of programming, I've never written a GUI interface so I have no idea where to start. help, tutor, pointers to samples would be most welcome. --- eric -- https://mail.python.org/mailman/listinfo/python-list
Re: need help with an accessibility prototype
On 05/22/2015 03:50 PM, Laura Creighton wrote: In a message of Fri, 22 May 2015 12:29:20 -0400, "Eric S. Johansson" writes: 2 needs. first is determining if NaturallySpeaking injects keycodes or ascii char into the windows input queue. second is building a test widget to capture and display text. I think I can solve both of these by building a simple text widget (tkinter? qt? ??) to capture keycodes. problem, is in yrs of programming, I've never written a GUI interface so I have no idea where to start. help, tutor, pointers to samples would be most welcome. --- eric The best online manual I know of for Tkinter is here: http://effbot.org/tkinterbook/ despite being 10 years old. But then I haven't looked for one for about that long, either. For tkinter key events are a bit odd, given that Tkinter tries to help you and considers special keys, punctuation and non-ascii printing characters as separate things should you want to bind to them. It's actually easier to write the code and say 'play with this' rather than to explain when you would need to use event.char and when event.keysym (Plus the code will tell you what Tkinter uses, I might remember wrong.) Save this in a file and run it. Wow. What a gift. It told me what I needed to know which is the key syms are generated in a way that makes sense to me as far as I understand them. A bit of background. I have some Linux resident code that translates standard input characters into key codes and then feeds them into uinput. the problem is, the character sequences generated by NaturallySpeaking plus Windows doesn't always work right or as expected. In theory, I should now be able to push the individual events over to the Linux side as key sym/ key codes, maybe do some translation, and ta-da, I now can dictate from the Windows virtual machine into Linux. I now have, within reach, a fair amount of accessibility added by simple open-loop keystroke macros. The RPC mechanism tied into the Python extension to NaturallySpeaking, it's possible to execute even more sophisticated speech user interfaces. thank you so much for the help. future trick will be synchronizing tkinter window on windows with one on linux --- eric -- https://mail.python.org/mailman/listinfo/python-list
parsley parsing question, how to make a variable grammar
In my quest for making speech friendly applications, I've developed a very simple domain specific language/notation that works well. I'm using parsley which is a great tool for writing parsers especially simple ones like the one I need. However, I've come across a problem that I don't know how to solve. Below is my grammar. The problem is the last element which aggregates all individual grammar elements. In my domain specific notation, it's possible for a user to create extensions and I'm trying to figure out how to make the grammar accommodate those extensions. The first Issue is adding more statements. I can handle that easy enough by splitting the existing grammar into a prefix, statements, and postfix. I could append more statements to the end of the statement section. When I'm done, I can then join all of the pieces together into a single grammar. The second issue is adding more elements between parentheses of bot so the additional statements can be included in the grammar. Seems to me, I should be able to create a Python expression which returns the OR list and it is interpreted as part of the grammar. Failing that, I'm just going to do a %s expansion when I create the grammar. I appreciate any insight before I go too far off track. --- eric TF_grammar = r""" kwToken = (letter|digit|'_')+ uses_statement = 'uses' ws kwToken:kwT ':' :roL -> do_uses ("".join(kwT), "".join(roL)) returns_statement = 'returns' ws kwToken:kwT -> do_returns("".join(kwT)) template_statement = 'template' ws kwToken:kwT -> do_template("".join(kwT)) remembers_statement = 'remembers' ws kwToken:kwT -> do_remembers("".join(kwT)) everything_else = :roL '\n'{0,1} -> do_everything_else ("".join(roL)) bot = (uses_statement | returns_statement | template_statement | everything_else) """ -- https://mail.python.org/mailman/listinfo/python-list
Re: parsley parsing question, how to make a variable grammar
On 6/14/2014 8:10 PM, Michael Torrie wrote: On 06/13/2014 03:05 PM, Eric S. Johansson wrote: I appreciate any insight before I go too far off track. --- eric Perhaps this is off-topic, and doesn't answer your question, but is Parsley a natural language parsing tool? If not, and if it is natural language that you're trying to parse, maybe you should see if the natural language toolkit would be more appropriate to your needs. Natural language is a rathole that many people go down when trying to build the speech user interface. In reality, all you need is something vaguely resembling normal language use. Something close enough to natural language that it's easy to remember but succinct enough that you don't burn out your speech capabilities. An example of this is my task log. It looks like this 16-Jun-2014 11:46 esj: start I did something today. No really. I started work on time and I finished on time 16-Jun-2014 15:46 esj: end day: 4 hours ... week: ... The speech grammar is "job stamp (start| end)". "Job stamp start" simply puts in the timestamp as seen above. "Job stamp end" adds the ending time stamp plus the day hours calculation. When I produce a report, the day and week numbers are recalculated in case I changed something manually. The calculation is then displayed so I can build an invoice. This model is speech friendly on two levels. Grammar is simple and automates is much as it can. Second, if I didn't have the grammar and macro capability, I could still speak the magic keywords without too much stress. There's another level of speech friendliness. I also have "time stamp"11:57, "date stamp" Jun 16, 2014, and "log stamp" 16-Jun-2014 esj: since they are all related and similar in construction, it's easier to remember. There's another aspect to natural language that is a bit of rathole. In my opinion, a good speech interface uses a combination of visual and speech elements. For example you should be of the see something on the screen and speak to it. This implies that the speech application can read the contents of the visual application so it can make the right decisions regarding grammar. This usually isn't possible because visual applications don't reveal appropriate content at the right level. The best we can do now is a bit of screen and menu scraping of highly decimated information that has lost all context. grumble -- https://mail.python.org/mailman/listinfo/python-list
Re: Captcha identify
On 8/12/2014 9:46 PM, Chris Angelico wrote: On Wed, Aug 13, 2014 at 11:36 AM, Wesley wrote: If my questions make you guys not so happy, I am sorry and please just ignore. I just wanna a general suggestion here in the beginning. Why I need to write such program is just having such requirements, and has nothing to do with the coding work itself. Don't say something to prove you're so noble. The general suggestion you're getting is: Do not do this. Many of us here use CAPTCHAs and spend time keeping one step ahead of those who try to break them with software. By writing something to solve CAPTCHAs, you would be stealing time from those people. Don't do it. Am I sufficiently clear? you are clear but also missing a really good reason to break captchas. handicapped accessibility. Captchas are a huge barrier to access and in many cases push disabled users away from using a service with captchas. For me (very acute vision, crap hands) it take me 2-5 tries before I get an image I think I can read reliably, then it take 2-3 tries to type the letters in (slowly and with hand pain) correctly. My mom (80yr and going strong) sees a captcha and gives up on using the site unless I tell her what to type. one major tests for accessibility is "can I automate common user tasks including tasks with context based decisions". Captchas fail that test as do many authentication system user interactions and, if one is entirely truthful, entire applications. Automating captcha solving would be a boon for the disabled or aging user. try taking this moment as a challenge. build an authentication system+ui that works for the disabled/aged and you will have an authentication system that will work better for everybody. for example, use an equivalent of ssh-agent to supply credentials to sites needing them. I can automate ssh-agent and we can make the process+UI easy enough for my mom to use it or automate it for her too. eliminate captchas, 35+million disabled people would thank you as would many more millions of the not-yet-disabled like your future self. -- https://mail.python.org/mailman/listinfo/python-list
Re: Captcha identify
On 8/13/2014 3:27 PM, Chris Angelico wrote: I agree with you, and I don't use CAPTCHAs on any of my services, anywhere, and never have. (Partly because they *are* broken by people writing scripts, and/or by just grinding them with human solvers; but also because of the problems they cause for legit users, even those with perfect eyesight.) However, the accessibility argument is one for the removal of the captcha, *not* for its automated solving. I will not support a scripted captcha solver for any reason. If you move away from a site because you can't use it, so be it. If you get a chance, tell the owner that there are alternatives to barely-readable images; tricks involving page layouts are almost always safe, and there's infinite room to play around in them. your suggestion reminds me of the time I asked front range for help with accessibility because I had to use Goldmine on the job. Immediately after I asked for accessibility information, they told me they don't have any accessibility information because they don't have any disabled users. Yes, they really did your suggestion will probably generate a similar response. There is no valid reason for automating something that's specifically to prevent automation. The admin needs to provide an alternative, instead. There is only one valid reason based in the fact that we don't own or control many of the sites we depend on. Therefore, if I need to use a site be it government or commercial and it has a Captcha, I need to pay some form of cripple tax by either incurring pain or find/pay somebody to type for me. In this situation I thing it is perfectly acceptable to automate bypassing Captcha's. -- https://mail.python.org/mailman/listinfo/python-list
Re: Captcha identify
On 8/14/2014 2:37 PM, Peter Pearson wrote: On Wed, 13 Aug 2014 14:16:02 -0600, Ian Kelly wrote: . . . and as computers get more powerful the intersection of {problems machines can't solve} and {problems humans can reliably solve} grows ever smaller. "Which of the following eight sentences are sarcastic in tone?" and responses on this list alone show problems with detecting sarcasm (or snark). -- https://mail.python.org/mailman/listinfo/python-list
Re: Captcha identify
On 8/14/2014 7:19 PM, Denis McMahon wrote: On Wed, 13 Aug 2014 07:39:20 -0400, Eric S. Johansson wrote: you are clear but also missing a really good reason to break captchas. handicapped accessibility. Captchas are a huge barrier to access and in many cases push disabled users away from using a service with captchas. That's as may be, but bozo is not trying to improve handicapped accessibility, he's trying to write a spambot. not necessary. you are probably right but he never described the application. Please don't use the accessibility concerns surrounding captcha to justify writing spambot software. It doesn't help the accessibility argument to be seen to be pro spambot, in fact if anything it may damage it. I agree that there are more reasons not to use captcha these days than there are to use them, however I still don't advocate helping spambot bastards defeat them. not what I said or advocated. pointing out that breaking captchas is good for accessibility issues it not the same as being pro spambot. it may have that effect but it is not the same thing. fwiw, making software accessible means making it possible to make your own interface via an application api. the current scrape-a-gui model fails the -what-the-user-needs test. at the same time, notice the huge security risk an D(ability)A(ccessibility) api opens up. does not mean we shouldn't use the DA api model, just that we also need to fix the security problem at the same time. -- https://mail.python.org/mailman/listinfo/python-list
need python+windows edit control help
I'm back with yet another attempt at adding accessibility features using Python and NaturallySpeaking. I've simplified the concepts again and I really need some help from someone who knows Microsoft Windows and Python. My goal is developing a template for what I'm trying to do, then I can take over and generate some useful accessibility tools. The core idea is an accessibility adjunct program receiving focus at start-of-utterance and returns focus to the original application at end-of-utterance. The window associated with the program contains a grid. Within the grid is an active cell which can accept input. Any cell could be made active depending on the state of the program but only one cell accepts input at any one time. How would this be used? For example, the Skype IM window is atrocious for its disabled users. If one associated at two cell window accessibility adjunct program with Skype, the user could dictate, edit, retrain, etc. within the adjunct program and on command, return the data to Skype. One could also contain a small history so that like Skype, you could go back and edit a previously sent message. a second use case is found on my blog http://blog.esjworks.com which is the tool to create mangled codenames from speech. I think the grid model works better than individual text fields that I originally wrote because it allows me to make better use of a cache of previously generated symbols. Anyway, if anybody can help, I would really appreciate some assistance. --- eric -- http://mail.python.org/mailman/listinfo/python-list
Re: need python+windows edit control help
On 10/21/2011 10:03 PM, Mark Hammond wrote: On 22/10/2011 10:30 AM, Eric S. Johansson wrote: I'm back with yet another attempt at adding accessibility features using Python and NaturallySpeaking. I've simplified the concepts again and I really need some help from someone who knows Microsoft Windows and Python. My goal is developing a template for what I'm trying to do, then I can take over and generate some useful accessibility tools. The python-wi...@python.org mailing list might be the best place to look for help - although you will probably need to provide much more information before anyone can help. MSDN documents most of what you can do with edit control (look for windows messages starting with "EM_"), but without checking, I expect you will find programs like Skype don't use a Windows edit control at all. Mark thanks for the pointer. When I talk about speech user interfaces in general and accessibility specifically, I find it's better to give a short overview (yes, this was short) before going into the details. I'll be clearer about what kind of help I need. --- eric -- http://mail.python.org/mailman/listinfo/python-list
bsddb3 locking questions
are there any simple examples of how to do record locking with bsddb3? the bsddb3 documentation is reasonably opaque. For example, the DB initialization requires a DBEnv instance for certain environmental features such as locking. but if you want locking, what happens next? I suspect the pattern goes something like the following but it's not clear from the documentation. dbe = DBEnv.open() (does the home directory need to be specified or is there a systemwide default? Is this per application or does a common pool work? dbe.set_lk_detect(...DB_LOCK_YOUNGEST) (but what about db_deadlock??? do I need a cron job?) dbe.lock_id() dbi = db.DB() dbi.open(..) (does the filename specified here need to be the same directory as the homedir in DBEnv or can it in a totally separate location? any advantages to either?) lock = dbe.get_lock() dbi.get/put dbe.lock_put(lock) (the above pattern is for record locking but for database locking, the lock get and put calls would bracket the open/close call) if you close the database, should you automatically close the env or (as I suspect) the database environment can cover one or more database specific incarnations but if you have access different databases, each one should have its own environment. anything else I'm missing? thanks for any guidance, ---eric -- http://mail.python.org/mailman/listinfo/python-list
Re: bsddb3 locking questions
Eric S. Johansson wrote: > are there any simple examples of how to do record locking with bsddb3? got this far with sample code from the activeware site filename = 'fruit' # Get an instance of BerkeleyDB db_env = db.DBEnv() db.set_lk_detect(db.DB_LOCK_YOUNGEST) db_env.open("/tmp/bsddb3",db.DB_INIT_LOCK|db.DB_CREATE) db_env.lock_id() stuck at lock_id(). it returns a 1 (failure according to the docs and there is no hint of where the lock id value is returned so I can use it in the lock_get call. at least that is what I think I need to do. -- http://mail.python.org/mailman/listinfo/python-list
Re: bsddb3 locking questions
man, I'm in really bad form replying to myself twice but I'me solved the problem at least in a simple form. Eric S. Johansson wrote: > Eric S. Johansson wrote: >> are there any simple examples of how to do record locking with bsddb3? #!/usr/bin/python from bsddb import db # the Berkeley db data base import sys, os, time # some helpers fcns def countdown(id, count): limit = 0 while limit < count: print id, limit, limit = limit+1 # fork into 2 instances and collide pid = os.fork() # Part 1: Create database and insert 4 elements # filename = 'fruit' # Get an instance of BerkeleyDB db_env = db.DBEnv() db_env.set_lk_detect(db.DB_LOCK_YOUNGEST) db_env.open("/tmp/bsddb3",db.DB_INIT_LOCK|db.DB_CREATE| db.DB_INIT_MPOOL) # force a collision time.sleep(2) an_id = db_env.lock_id() print pid, an_id fruitDB = db.DB(db_env) # Create a database in file "fruit" with a Hash access method # There are also, B+tree and Recno access methods fruitDB.open(filename, None, db.DB_HASH, db.DB_CREATE) # Print version information print '\t', pid, db.DB_VERSION_STRING while(1): try: lock = db_env.lock_get(an_id, "anytid", db.DB_LOCK_WRITE, db.DB_LOCK_NOWAIT) break except Exception,error: #print error pass print pid, "here" # force another one time.sleep(2) # Insert new elements in database fruitDB.put("apple","red") fruitDB.put("orange","orange") fruitDB.put("banana","yellow") fruitDB.put("tomato","red") db_env.lock_put(lock) print pid, "there" # Close database fruitDB.close() # Part 2: Open database and write its contents out # fruitDB = db.DB(db_env) # Open database # Access method: Hash # set isolation level to "dirty read (read uncommited)" fruitDB.open(filename, None, db.DB_HASH, db.DB_DIRTY_READ) # get database cursor and print out database content cursor = fruitDB.cursor() rec = cursor.first() while rec: print rec rec = cursor.next() fruitDB.close() -- still unanswered, under what conditions do you change the second argument of lock_get? Is that a simple lock identifier within the context of the lock ID so that you can lock different records? Anyway, this locking is close enough for what I need to do. ---eric -- http://mail.python.org/mailman/listinfo/python-list
Re: How to lock files (the easiest/best way)?
Elmo Mäntynen wrote: > Is there something better than using fnctl? It seems a bit intimidating > with a quick look. try the portlocker wrapper from the active state cookbook. I have a version which has been slightly updated for more modern pythons. I really need to make my darcs repository visible so you could get it. Alternatively, you can try the makedir trick. Creating directories are atomic operations if it exists, you will get error message. If it doesn't, you will get a directory and thereby capture the lock. You delete the directory when you release the lock. crude but effective. I used it in building a file based queue system. You know, I really should learn how to build eggs because I have a whole bunch of little pieces of software that would probably be useful to others. ---eric -- http://mail.python.org/mailman/listinfo/python-list
Re: What do you want in a new web framework?
[EMAIL PROTECTED] wrote: > hardemr wrote: > >> I've just read all of the answers. Most of yours said that there are >> many web frameworks ,so it is nonsense to make a new web framework in >> python. > > Hardemr, I like Ajacksu's answer, with a twist. Please concnentrate on > writing a Visual Studio-like gui designer, and make it possible to add > your Visual Studio like gui designer to Django (and TurboGears, et al). it only make sense if you are disabled (visual or upper limb). most if not all web frameworks are "no cripples need apply". why? mixed caps, mixed modes (i.e. html+python), crappy editors to start. these few items have such a *huge* impact that it can mean the difference between being able to do the job or not. if you want to make a diff, make an IDE that works for the blind and the mobility impaired. the work has been started but it needs labor (see voicecoder project). second place to make a difference is to build a bridge between windows and gnome at-spi so one can speak (NaturallySpeaking on windows) then have the effect show up on linux. but in the context of web frameworks, my hp friendly framework shows how easy it is to make apps HP friendly. the framework is rtg except for packaging (and some docs). (I'm having problems trying to understand and speak the setup file at the same time.) If you want specific examples handicap barriers, I'll tell you after my new mic arrives and my hands stop hurting so much. my cost: this message means 30-40 min timeout for the nerves to cool off. --- eric -- http://mail.python.org/mailman/listinfo/python-list
distutils:permissions problems
I'm developing Python code on multiple VM Ware guest OS running ubuntu. I need to share common file space so that each of these guest instances will have complete access to the to all of the files. The problem is that, because of a quirk (or misfeature) of VM Ware shared filesystem, all of the directories and files are owned by root with a 700 permissions. When I run setup.py install, they are installed as root with 700 permissions. How can I alter the behavior of distutils so that my modules could be installed with a more useful user and permissions? many thanks ---eric -- http://mail.python.org/mailman/listinfo/python-list
Re: distutils:permissions problems
Martin v. Löwis wrote: > Eric S. Johansson schrieb: >> The problem is that, because of a quirk (or misfeature) of VM Ware >> shared filesystem, all of the directories and files are owned by root >> with a 700 permissions. When I run setup.py install, they are installed >> as root with 700 permissions. How can I alter the behavior of distutils >> so that my modules could be installed with a more useful user and >> permissions? > > I recommend to change the permissions after the files have been > installed. If you absolutely have to change setup.py, you should inherit > from the install_lib and install_scripts commands, and either override > the "install" method to install using a different umask, or you should > look at the get_outputs() result of the command, and modify the files > after they got installed. > > You might also try changing your umask. thank you for your kind reply. I have already tried changing umask. The vmware filesystem has its own interpretation of permissions and access which bears absolutely no resemblance to either the UNIX or the NT models. It feeds false data into the system and well, we get to have this conversation. :-) I'm currently changing permissions afterwards and that's a source of installation breakage because the same information is stored in multiple places. I might be able to unify things if I can figure out how to make all components reference everything in a setup.cfg file. your suggestion about modifications isn't all that horrible because I'm already doing a significant amount of work that isn't covered by the distutils code as documented. thank you for the pointers to additional functionality that might be useful to me. ---eric > > Regards, > Martin > -- http://mail.python.org/mailman/listinfo/python-list
Re: Getting a lot of SPAM from this list
[EMAIL PROTECTED] wrote: > Gabriel> I use a discardable email address from Yahoo. Spam filtering is > Gabriel> good, and when you get too much spam, just delete that address > Gabriel> and create another one. > > Maybe it's just me, but creating and discarding email addresses makes me > think the spammers have won. I'd prefer to face them down at high noon. > Six guns at twenty paces (figuratively speaking, of course). using a baseball bat to chase them across one or more yellow jackets nest work for me. But to address your issue about spammers having won, I would argue that they have. mailing list archives are cluttered with so much junk they're useless, people are losing e-mail they should otherwise get, folks are abandoning e-mail addresses rendering contact information on webpages and memory useless. Filters are not the answer. Filters are actually the problem because since they operate on a probabilistic basis, spammers gain more visibility by increasing traffic. Filters improve, volumes go up. It's gotten so bad, people are making serious plans to introduce identity-based systems to authenticate servers and possibly even addresses. What's scary is that this kind of technology can be easily abused by various powers to shut down the ability to speak. Just think about the judicial load needed to adjudicate complaints in either direction. I have a solution that has been working for me for the past three or four years. I'm almost done with the next release (I pray) with a better installation process as well as improvements throughout the system. I'll post the announcement here when things are working. ---eric -- http://mail.python.org/mailman/listinfo/python-list
distutiles extension question
How can I limit when my code run only when it's a build or install setup.py command and only after the setup method? I need to do some processing after setup.py runs and I've been successful writing the code to do what I need but the problem is it runs every time I run setup.py regardless of the command following. looking in build.py, I found and internal array called sub_commands and it looks like that would be a good place to add my postprocessing but I can't figure out quite how to get my code into the right context. some pointers would be appreciated. Thanks for your time. ---eric -- http://mail.python.org/mailman/listinfo/python-list
Re: [*SPAM*] Python open proxy honeypot
Alex Reinhart wrote: > Yeah, I just realized that. What would I do to act as an open proxy as well? emulate the Apache proxy capability, especially the reverse proxy. more seriously, what you need to do is from common proxy and web server ports, accept proxy requests with a destination port number of 25 and pretend to relay them. at least, that was the behavior I saw on a misconfigured Apache web server proxy. for what it's worth, I advocate abandoning Apache as it is too complex to configure correctly quickly. This is especially true of the built-in proxy. For what it's worth, folks should consider using alternatives like pound (very good secure proxy) and Cherokee (my favorite). But seriously, any web server except IIS is better than Apache. Find one that works for your application and use it. ---eric -- http://mail.python.org/mailman/listinfo/python-list
question on dict subclassing and overriding __setitems__
I apologize if this is an FAQ but googling has not turned up anything, at least to my keywords. I need to parse a configuration file from an existing application and I'm treating it as a dictionary. I created my class with a parent class of dict. Everything works okay except I discover I need to force keys to uppercase when setting a value. I override __setitems__ and, as you'd expect, I get a recursive loop. I'm obviously missing a clue on how to break the recursion. My admittedly simpleminded method overloading looks like: def __setitem__ (self, index, value): """force keys to uppercase""" self[index.upper()] = value thanks for any pointers. -- http://mail.python.org/mailman/listinfo/python-list
Re: question on dict subclassing and overriding __setitems__
Diez B. Roggisch wrote: >dict.__setitem__(self, index.upper()) = value oh duh. > Or better even > >super(subclass, self).__setitem__(key.upper(), value) hmm. http://fuhm.net/super-harmful/ I think I need to do some more reading. ---eric -- http://mail.python.org/mailman/listinfo/python-list
Re: [*SPAM*] Python open proxy honeypot
Alex Reinhart wrote: > Eric S. Johansson wrote: >> Alex Reinhart wrote: >>> Yeah, I just realized that. What would I do to act as an open proxy as >>> well? >> emulate the Apache proxy capability, especially the reverse proxy. >> >> more seriously, what you need to do is from common proxy and web server >> ports, accept proxy requests with a destination port number of 25 and >> pretend to relay them. at least, that was the behavior I saw on a >> misconfigured Apache web server proxy. > Is there a library that implements such functionality (that I can > override) or will I have to implement SOCKS and such myself? I've found > one SOCKS library and it's rather old and out of date... I'm not sure. I would seriously look at the Apache code in figure out what it does differently. The other possibilities look at the pound code which is probably more comprehensible and a better example of secure code. It's not out yet but I believe Cherokee will have a proxy soon. I advocated filtering out anything with a port 25 destination. After they heard my experience with Apache, they thought it was a real good idea. :-) -- http://mail.python.org/mailman/listinfo/python-list
need all python dialog equivalent
I'm creating a dialogue style interface for an application on a dedicated system. All I have is basic Python 2.3. Is there anything like an all Python dialog equivalent floating around? I'm currently hacking away in curses but it's taking me a long way down what I fear to be a wrong path. I've looked at the Python dialog web site but it clearly states that it is a wrapper around dialogue/Xdialog. suggestions would be most welcome. ---eric -- http://mail.python.org/mailman/listinfo/python-list
Re: need all python dialog equivalent
[EMAIL PROTECTED] wrote: > dialog binary is 110 KB. Won't it fit ? missing library. I have ncurses and newt and dialog seems to require something called ncursesw. I've been trying to find the Python newt module as well and that seems to be as invisible as the creature it's named after. -- http://mail.python.org/mailman/listinfo/python-list
Re: need all python dialog equivalent
Miki wrote: > Hello Eric, > >> Is there anything like an all Python dialog equivalent floating around? > http://www.pythonware.com/library/tkinter/introduction/ I'm sorry. I should have been more explicit. I need a textbased interface such as the ones you would get with curses and dialogue. ---eric -- http://mail.python.org/mailman/listinfo/python-list
Re: need all python dialog equivalent
Fredrik Lundh wrote: > Eric S. Johansson wrote: > http://excess.org/urwid/ ? I just found that about an hour ago. the demos work on the target system so I'm comfortable enough to go down that path. thank you all. ---eric -- http://mail.python.org/mailman/listinfo/python-list
Re: need all python dialog equivalent
Thomas Dickey wrote: > Eric S. Johansson <[EMAIL PROTECTED]> wrote: >> [EMAIL PROTECTED] wrote: >>> dialog binary is 110 KB. Won't it fit ? > >> missing library. I have ncurses and newt and dialog seems to require >> something called ncursesw. I've been trying to find the Python newt > > "seems to require" if you're installing some package. > dialog builds/works against either ncurses/ncursesw ncursews was what the binary image of dialogue was complaining about. But that's all behind me now because I'm using http://excess.org/urwid/ as was suggested by someone else. So far, it works pretty well. There are errors reported that aren't obvious in terms of what they indicate but like others software packages, once you acquire the scar tissue, it becomes something you tolerate. ---eric -- http://mail.python.org/mailman/listinfo/python-list
Re: list comprehension
tac-tics wrote: > a wrote: >> can someone tell me how to use them >> thanks > > sigh... > You do a google on them: > > http://docs.python.org/tut/node7.html#SECTION00714 > thank you for the reminder. But after reading it, I was left with a question. Why the new syntax for what appears to be nothing more than a different way of expressing nested for loops? at first I tried rearranging the one of the examples from the previously referenced document to clarify (in my mind) what was going on: [x*y for x in vec1 for y in vec2 ] then when I tried to rewrite it as a nested for loop, that's when I realized list comprehensions is a method of returning the calculation in the interior of a for loop as an assignment without requiring aggregation of results in a temporary variable. so a double thank you to you because you've clarified something that has been a mystery to me for awhile. now if I could find someone to explain distutils and eggs so that I understand that as well... ;-) Heck, I would even settle for a wizard tool generating the first approximation for me. ---eric -- http://mail.python.org/mailman/listinfo/python-list
building helper executables with distutils
I have a module which needs to invoke a suid helper program in order to do what it needs to do. This suid helper program needs to be built and installed at the same time as the module. Is there any way to do this with distutils? I've been looking through the documentation but haven't really found any way to do it except maybe by invoking a system call running a script to do the suid build process. -- http://mail.python.org/mailman/listinfo/python-list
Re: Python blogging software
Fuzzyman wrote: > > Because it is client side (rather than running on the server), it has > no built in comments facility. I use Haloscan for comments, but I'm > always on the look out for a neat comments system to integrate with > Firedrop. > > I personally prefer the 'client side' approach, as it makes migrating > content to another server trivially easy. a wise person you are. I've often thought that most of the pages generated by web frameworks (except for active pages) should be cached once rendered. as to the comment system, I've been very disappointed by most blog comment capabilities because they actively hinder the ability for commenters to interact with each other. what I would like to see is a short-life (i.e. three day) mailing list where the message history is stored as if it were blog comments. The advantage of this technique is you can follow the comments without constantly checking in on the blog And you can actually build a community which interacts more easily than they do today. Yes, you could build a web form techniques but the main advantage of Web forms over mailing lists is that they fill your mailbox with messages telling you that you have a message instead of delivering the message itself. it would be interesting to see if one could build this capability into/out of mailman. I really hate reinventing the wheel unless the wheel is square and I need a round one. :-) ---eric -- http://mail.python.org/mailman/listinfo/python-list
sgid and python programs
Assuming one can't avoid the need to set the group ID of a Python program, is a wrapper program still considered the best way to do that? the reason I ask is that a few years ago, I picked up a program that was (and maybe still is) shipped with Python as a wrapper for sgid programs. I searched but Google still tells me as much now as it did then about Python and changing the effective group ID (i.e. not very much). Thanks for any council or advice on the matter. ---eric -- http://mail.python.org/mailman/listinfo/python-list
Re: R.S.I. solutions?
Nick Craig-Wood wrote: > This is excellent advice... I was diagnosed with tendonitis over 5 > years ago now. I found the medical people generally hopeless, but the > physios really know their stuff (this is in the UK also). some know their stuff but a vast majority of them are humming because they don't know the words. 12 years ago, I went through a whole bunch of doctors including physiotherapist etc. and they all just kind of said "sucks to be you". Now, after having been stable for 10 years, the pain is getting worse again. This time the nerve conduction studies show compression and it's off to the neurologist I go. I expect a second round of "sucks to be you" Now the list of things he suggested are basically sound but only work for a small proportion of people injured. This is the real big indicator that the medics don't know what they're doing or even have a vague understanding of the problem. We would get just as good a result if we gave people tonics and told them to stay out of the miasmic vapors of the lowlands. > 2) Get your workplace right! chair height, screen height, distance to > keyboard etc. The physio can advise here. it is exceptionally difficult to do this yourself even if you are well-educated. The reason being is that you need somebody else from the outside to look at how you are sitting. You also need someone to visit and evaluate your workspace. > > 3) The physio recommended a rolled up towel as a wrist rest - for me > that is just the thing. It is large and soft. my problem is a different one. Most keyboards are to narrow for me. If you have the classic IT profile (i.e. spare tire), your elbows will be pushed out and your hands will want to form a / \ position to the keyboard and as a result, you will twist your wrists outward to make them parallel so you can easily get the keys. I have seen even normal weight large men have problems with keyboard width. The only people who haven't had problems are typically women under 130 pounds. It would be really nice to find a keyboard with a wide center space and no keypad. The other thing to pay attention to are the keys themselves. Many keyboards today are garbage. Cheap ( but not necessarily inexpensive) keyboards including the Microsoft natural, have sticky keys that make you use too much pressure in order to get a keystroke and then frequently you will bottom out with a sharp shock. At any one time, out of a selection of 30 or 40 different keyboards I might find one with acceptable keys. What's really strange is that most people think laptop keyboards are horrible but I absolutely love the ones I've had from Dell and Acer laptops. the Acer one is truly remarkable because the keyboard is arranged in a smiling face which accommodates my greater width without being obnoxiously wide. If only they would put that on a desktop keyboard, I would be very happy. In terms of key pressure, that's also wonderful. It's lightweight and I barely have to touch them. IMO, it's a win. > 4) I swapped my mouse usage to the left hand (my right hand was > worse). It took a few months to get used to but it feels totally > natural now. I can now mouse with both hands just fine. I'm currently using a trackball although the best input device for me has been a tablet with pen. I do wish the pen was fatter and cushier but that's something you can do to using some foam if there's some way to keep the pen side buttons available. see wacom for the 4 x 6 tablets. Be aware however that a pen costs almost half a tablet and are only available over the mat so that when a pen breaks, it is frequently cheaper/easier to throw a tablet away and buy a new one than it is to replace the pen. > RSI is a complicated disease - there are lots of different forms of it > all caused by different things. You'll need some professional advice > to sort it out. and lots of whom don't know what they are doing. you will be pushed in different directions and the only thing I will say to stay away from is surgery. Especially for ulnar nerve transposition. I do not know a single person that that has helped investing lots of people with scars all over their arms and neck from surgeons mucking about with nerves like they were Dr. Frankenstein creating new life. the rule of thumb is: try anything you want but stay away from anything you can't go back and get seconds. which reminds me. It's incredibly easy to gain weight at the best of time for geeks like us. If you are hurting, in lots of pain, and feeling very isolated, it's really easy to gain even more weight if you seek solace in food. It's hard but try to resist. Gaining weight will make the symptoms worse but losing the weight afterwards won't always make you feel better. Do what you can with the parts of your body that aren't hurting. Go walking, put together the money for a recumbent bicycle (under seat steering is a godsend if you like
Re: R.S.I. solutions?
Dennis Lee Bieber wrote: > On Tue, 26 Sep 2006 15:03:41 -0400, "Eric S. Johansson" <[EMAIL PROTECTED]> > declaimed the following in comp.lang.python: > >> What's really strange is that most people think laptop keyboards are >> horrible but I absolutely love the ones I've had from Dell and Acer > > They are... There is no height stagger on the keys... Hitting the > lower rank requires pulling one's fingers UP as you draw the tip back, > and going nearly flat to reach the upper ranks (which, for my short > fingers, means I tend to hit both the upper rank and the home row at the > same time) that explains it. My hands are larger than most. On a typical PC keyboard, I can hold down the control key with my little finger and hit all alphanumeric keys without straining (too much). ... Strokes are too short to -- I learned to type with old > typewriters, where the technique was to "snap" at the keycap to get > inertia to complete the stroke; one's fingers did not follow the key cap > all the way to the end of the stroke, but was pulling back for the next > stroke while the mass of the letter-head and key mechanism kept the key > moving down. never learned that trick. Even with the old typewriters, I drove the key all the way home. (Are we the only people on this list that actually used a manual typewriter complete with carbon paper and whiteout?) but I do like short stroke because it is less finger movement and because the underlayment a laptop keyboard is more flexible than a desktop keyboard, I get some bounce which reduces the end of travel shock. The problem I have with current keyboards is that there is so much resistance on the keystroke that you have to force the key all the way down until you hit bottom hard. At least, that's the way it feels to my fingers. > Of course, even desktop keyboards aren't designed properly -- using > the tilt-feet gives a usable slope on the keys, but also changes the > angle of the keys... Instead of pushing the key vertically, one now has > to push them "away"... yeah, given a choice, I would push most keyboards away. > > And does anyone remember when key caps were double-injection molded, > rather than dry-transfer lettering? I might even still have a couple in the basement. some of the keys don't work but they still go clack-clack-clack when you drop them. ---eric -- http://mail.python.org/mailman/listinfo/python-list
Re: Making sure script only runs once instance at a time.
Hari Sekhon wrote: > I have written a script and I would like to ensure that the script is > never run more than once at any given time. > > What is the best way of testing and exiting if there is another version > of this script running somewhere on this machine? > > I guess what I'm asking is how to handle system processes the way I can > in shell. I am running this on linux. assuming that you're limiting the script to one running instance of a given system, I would recommend searching the list archives for a file locking discussion of a few weeks ago. I had made a post suggesting portalocker as simple way to achieve file locks. Somebody else gave a really good discussion of a variety of locking techniques. the basic technique you want is to use some file as a semaphore, lock the file, run your script, and unlock on completion. choose the right locking mechanism, and the lock will go away when the process exits which helps on cleanup from abnormal terminations. ---eric -- http://mail.python.org/mailman/listinfo/python-list
another distutils question
is there anyway I can, in a setup.py file, set and internal equivalent to the '--install-scripts' commandline option? script installation directory but I don't want on the command line where things can go horribly wrong if the user forgets. I would like to create a new default setting for this commandline option as well as a couple of other such as the data default directory. --- eric -- http://mail.python.org/mailman/listinfo/python-list
Re: another distutils question
Robert Kern wrote: > Eric S. Johansson wrote: >> is there anyway I can, in a setup.py file, set and internal equivalent >> to the '--install-scripts' commandline option? > > Please don't. Hard-coding that interferes with the user's decision of where > things should go. Only the user should be making that decision, not the > package > author. I understand the concern and if I was making a general purpose package, it would be appropriate to not set the path. But these are internal commands that shouldn't pollute /usr/bin for a variety of reasons (almost all daemons, friends of daemons and cgi programs). The CGI programs are particularly interesting because they are all surrounded by sgid wrappers and I need to put them in a place the wrapper can find them and keep them from accidental corruption. distutils is not particularly adept at handling such cases. But the second reason to force the path is to reduce errors at install time (i.e. reducing the number of places someone to make a mistake if they want to use the application defaults). Ideally, best of both worlds would be enabling application specific override of the internal default which, in turn, can be overridden with the commandline setting. if there is no simple way to do this, I guess I will need add functionality to setup.py and move the scripts to the right location after they have been put in the wrong one. ---eric -- http://mail.python.org/mailman/listinfo/python-list
Re: another distutils question
Robert Kern wrote: > > Okay, if it's just for internal use, then I certainly have no objection. Use > a > setup.cfg file: > >http://docs.python.org/inst/config-syntax.html > > Specifically, use something like the following section: > > [install] > install_scripts=/path/to/scripts/directory > thank you thank you thank you. That was the magic bit of missing information. Now I get to puzzle out how to install the CGI plus images plus stylesheets plus plus plus mess. Probably a bit outside of the scope of distutils even if the CGI programs are Python. ;-) ---eric -- http://mail.python.org/mailman/listinfo/python-list
Re: another distutils question
Robert Kern wrote: > Eric S. Johansson wrote: > >> Now I get to puzzle out how to install the CGI plus images plus >> stylesheets plus plus plus mess. Probably a bit outside of the scope of >> distutils even if the CGI programs are Python. ;-) > > I recommend installing the data inside the package itself. In 2.4, use the > package_data keyword in setup(). > >http://docs.python.org/dist/node12.html 2.4 is good. Eventually I will upgrade to eggs but I'm making enough changes right now to make me crazy. maybe I am over thinking this problem. I needed a CGI scripts to go to a predictable place so I can build the wrappers. For all I care, that could be another Python module in the site-packages hierarchy (assuming they are executable). But I have separate targets for the images etc.. The reason being that I organize my sites as /var/www/{html,data,images)/. Don't ask. So what I have seen so far says that to be able to take data from a series of directories scatter it to other directories may be out of scope. It's okay. If I have to write a wrapper, it won't be the first time. --- eric -- http://mail.python.org/mailman/listinfo/python-list
Re: another distutils question
Eric S. Johansson wrote: > So what I have seen so far says that to be able to take data from a > series of directories scatter it to other directories may be out of > scope. It's okay. If I have to write a wrapper, it won't be the first > time. do'h. http://docs.python.org/dist/node13.html -- http://mail.python.org/mailman/listinfo/python-list
Re: another distutils question
Keith Perkins wrote: > > On a similar note , I have another question about distutils and data files. > I have a little program that uses a txt file to store data, and it works > fine running it in it's own folder, if I install through distutils, using > sudo to get it to write to the site-packages folder (which root owns), it > installs the data file so that it is owned by root, and not by me, so > that the data file can't be written to (although the script can read it). > Do I need to run a post install script, or add something to setup.py file > to chown the file or am I doing something wrong? There doesn't seem to be > anything on this in the docs. 1: as pointed out, site-packages is for code only :-) 2: you will need a post processing script. here is an example of distutils abuse that may help a little bit. I needed to collect files from a file hierarchy and one other place in the source directory then stuff them in the right place in the production directory. Since the pattern was unpredictable, I built a method to accumulate data file references. the solution is a bit more hard coded than I like but it gets the job done for now. as I need to improve it, I'll fix it. def expand_hierarchy(starting_point, data_files): dir_files = os.walk(starting_point) for (path, name, files) in dir_files: x = os.path.basename(path) if x != 'CVS': clean_files = [ os.path.join(path,item) \ for item in files \ if (clean_test(item)) ] data_files.append((cr_paths%path,clean_files)) return data_files setup(... data_files=expand_hierarchy("web-ui", [(cr_paths%'etc', ['ancillary/baseline_configuration']), ], ) to solve the file perms problem you run something after setup. how you associate perms/ownership with a file is up to you. It might work to use data_files to enumerate files you apply the common perms/owernship. then special case what you need to. hope this gives you some useful ideas. --- eric -- http://mail.python.org/mailman/listinfo/python-list
Re: another distutils question
Robert Kern wrote: > Instead, include the default data inside the package (read-only to non-root > users). Then allow the script itself to create the directory the first time > it > is run (read-write, and it should then automatically be accessible to the > user > that ran the script). You might also add a command-line option to *only* > install > that directory. I would be okay with a package/data/... arrangement if and only if the data within that directory was read only and only changed when the package changed it. System specific changes would be in a system copy of the configuration file and user specific changes would be a user copy. If you create a configuration system which uses a union of all three configuration files, you eliminate unnecessary replication of configuration values, minimize changes necessary when the baseline configuration file changes, and you also have the opportunity to control scope of configuration variables. I.e. some that are only changed in the system config file. I have an application dependent version of this I've been using for the past three years and, it's really nice. It lets me mostly ignore the configuration files and focus on what I'm trying to solve. --- eric -- http://mail.python.org/mailman/listinfo/python-list
Re: Making sure script only runs once instance at a time.
MonkeeSage wrote: > Here's a class using Fredrik's suggestions to provide generic, > cross-platform file locking (only tested on *nix however, with the two > test files listed [i.e., run test1.py in one terminal then test2.py in > another]): > > http://pastie.caboo.se/15851 > > Ps. The lockfile should also always be cleaned up (even when your > program excepts) because of the magic __del__ method, but I don't > guarentee it will be (nor depend on it: I used the pid + hostname in > the lockfile approach). the problem with this solution is that it does not handle the read nonexclusive/write exclusive locking model. In this model, reads don't block, they only register that the request is in process. writes lock request block until all outstanding reads have completed. When there is a write lock waiting, all subsequent reads lock requests block until the write has completed. Things get more complicated when you add exclusive read capability to the system. But fortunately, that capability isn't needed very often and sometimes reduces to a write exclusive lock. The next level up in terms of locking system requirements is some form of scoreboard mechanism where you can lock individual records in a file (i.e. dbm). I do something like this in a demon which owns the dbm, mediates database access, and record locking so that I can have multiple readers and writers at the same time using gdbm. But you can also use the same technique for metakit. ---eric -- http://mail.python.org/mailman/listinfo/python-list
Re: httplib and large file uploads
Jesse Noller wrote: > Hey All, > > I'm working on an script that will generate a file of N size (where N is > 1k-1gig) in small chunks, in memory (and hash the data on the fly) and > pass it to an httplib object for upload. I don't want to store the file > on the disk, or completely in memory at any time. The problem arises > after getting the http connection (PUT) - and then trying to figure out > how to iterate/hand the chunks I am generating to the httplib > connection's send() call. For example (this code does not work as is): I've been wrestling with a similar one for a while and been mostly held up because the Java applet developer has been... less than prompt. The only way I've been able to successfully upload very large files is by performing multiple put requests and on the server-side aggregating them into the "real file". obviously, world will be more difficult if you don't have a uniform chunk size or sequential creation of chunks. ---eric -- http://mail.python.org/mailman/listinfo/python-list