Re: [Tutor] OT looking for help creating a thumbnail
On Tue, 2008-07-22 at 16:17 -0700, johnf wrote: > Hi, > I'm sorry this is OT but you guys are very knowledgeable with the world of > python. I already tried the python list. - no response. > > I need a py tool that will provide a thumbnail (bmp?) from a video (avi, > wmv) that will be cross platform (linux, windows). Research has provided > pymedia for Linux but I haven't found anything for windows. Hopefully, > someone has had to do this in the past and knows what has to be done. > > Thanks in Advance, > Johnf > http://code.google.com/p/pyffmpeg/ Licence: LGPL. There's a nice sample code. Hope this is what you're looking for. Ziyad. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] [Off-Topic] 'vimrc' for Python...
(Sorry for hijacking the thread. This is the second time in the same day... sigh!) On Thu, 2008-02-28 at 08:04 -0500, bhaaluu wrote: > I also run Python on Linux. I've tried several of the Python IDEs > (Integrated Development Environments), such as IDLE, Eric, and > so forth, but the best (for me) has been vim. I agree. > I use the following > .vimrc file: > > -8<-Cut Here->8--- > " .vimrc > " > " Created by Jeff Elkner 23 January 2006 > " Last modified 2 February 2006 > " > " Turn on syntax highlighting and autoindenting > syntax enable > filetype indent on This should be: if has("autocmd")" If Vim is compiled with support for 'autocommands'... filetype indent on " ...turn on indentation accordingly. endif > " set autoindent width to 4 spaces (see > " http://www.vim.org/tips/tip.php?tip_id=83) > set et > set sw=4 > set smarttab Not good. This will turn the above for all files edited with Vim. Here's a better setup (note: some of the lines bellow are longer than 80 column which might get wrapped by you mail reader! sorry.): if has("autocmd") " Only do this part when compiled with support for 'autocommands'. autocmd FileType python set ts=4 sw=4 et" Python autocmd FileType ruby set ts=2 sw=2 " Ruby autocmd FileType c,cpp set ts=4 sw=4 cindent " C & C++ autocmd FileType docbk,html,xhtml,xml set ts=2 sw=2 " DocBook, HTML, XHTML, and XML endif " has("autocmd") (You can add more specific options for any other file types you wish for.) > " set line number (added by bhaaluu) > set nu > " Bind key to running the python interpreter on the currently active > " file. (courtesy of Steve Howell from email dated 1 Feb 2006). > map :w\|!python % Grate! (You could use ':update' instead of ':w' which will write the file only if it has changed.) > -8<-Cut Here->8--- > > I run vim in Konsole, but any Xterm works, AFAIK. > > Happy Programming! Happy programming to all of you out there. Ziyad. (again, sorry for hijacking the thread!) ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] [Off-Topic] 'ex' vs. 'sed'...
(sorry for hijacking the thread like this!) On Wed, 2008-02-27 at 15:02 -0800, Bill Campbell wrote: > Another way on *nix systems that might be better wouldn't use > python at all. Edit the file in place with ed or ex: > > #!/bin/sh > ex - filename < 1d > w > q > DONE > E, how about: "sed -i.BACKUP -e '1d' filename"? Much shorter, elegant, and obvious. (and it creates a backup file of the original.) After all, "sed" stands for: Stream EDitor. Ziyad. (again, sorry for hijacking the thread.) ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] What web framework?
On Mon, 2008-01-28 at 16:35 -0800, Terry Carroll wrote: > - this application will be query-only; no updating, adding or deleting. > - the database is SQLite. > - security and authentication are not important; there's no private data > here, I'm the only user, and I'm firewalled. If a particular framework > has security features, I'll use them, but I don't see them as important. > (Famous last words.) > > I'd like something that doesn't take forever to get up to speed on, but > that isn't short on features. Although this is the only framework project > I see in the immediate future, I can imagine I might want to do another > project sometime in the future. I really want to be framework-monogamous > here: I don't program for a living, and getting up to speed on a framework > seems like work to me. Try: http://webpy.org/ About WebPy: web.py is a web framework for python that is as simple as it is powerful. web.py is in the public domain; you can use it for whatever purpose with absolutely no restrictions. Tutorial: http://webpy.org/tutorial2 Hope this will help you. Ziyad. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Mobile Python
On Mon, 2007-12-31 at 16:02 -0800, Dave Kuhlman wrote: > On Mon, Dec 31, 2007 at 12:12:34PM -0500, Antonio Salgado wrote: > > Hello to everyone and wishing you all the best and succes in this new > > year!! > > Well i'm wondering if someone can point me out or help on this, I want to > > write apps for mobile devices, but for the regular nokia (like the 5300), > > but i haven't find documentation or anything. Hope someone can help me. > > My best wishes and greeting from Mexico!! > > Try doing a Web search for "python s60 pys60". That won't help Antonio. Nokia 5300 is *not* an S60/Symbian mobile device. > > Among other links, you will find: > > http://wiki.opensource.nokia.com/projects/Python_for_S60 > http://sourceforge.net/projects/pys60/ > > There is an emulator, so you can test some of your code without > even loading it onto a cell phone device. > > This sounds like exciting stuff. Please keep us informed about > your progress. > > - Dave > As for you Antonio, I don't think Python will run on that device. It's an S40 device, which is a propriety platform from Nokia. Nokia published documentation on how to program it only through "Java ME" and nothing else! You either need to contact Nokia directly to obtain the closed API (and then port Python to it), or use Java ME to interact with your device. Does anyone know if Jython will help in this situation? (or am I way off, and Jython is not used like that?!) Hope that help. Ziyad. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] n.isalnum() is failing
Terry wrote: > Hi! > Hi... > I am using x.isalnum() to check that I have a number for each year > entered, and it doesn't look to me like it is functioning properly. That's because "x.isalnum()" will return True if "x" is not empty and it's content are *either* an Alpha or a Number (which is not what you want)! You need to use "x.isdigit()" for your need. Typing "help(str)" inside the Python shell will read: | isalnum(...) | S.isalnum() -> bool | | Return True if all characters in S are alphanumeric | and there is at least one character in S, False otherwise. | | isalpha(...) | S.isalpha() -> bool | | Return True if all characters in S are alphabetic | and there is at least one character in S, False otherwise. | | isdigit(...) | S.isdigit() -> bool | | Return True if all characters in S are digits | and there is at least one character in S, False otherwise. Ziyad. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Infinite Loops (and threads)
Luke Paireepinart <[EMAIL PROTECTED]> On Sun, 24 Dec 2006 10:02:19 -0600 wrote: > Kent Johnson wrote: > Kent et. al., > > I'm writing something that has to do with sockets. > I need to recv any incoming packets from the socket. > I will have potentially hundreds of separate sockets open in a single > application. > I was just going to create a thread for each, so I could receive from > them separately. > > Alternately, I figured I could read from each socket in sequence if I > could get the recv method to not block until it gets input, > so I tried this, > > Thanks, > -Luke Use "import select" and read about it for more information (i.e. help(select) within Python shell). I advice you (and others interested in writing Python code dealing with sockets) *very strongly* to read the following: http://www.amk.ca/python/howto/sockets/ (Currently, I'm having trouble accessing that URL. I don't know if it's my ISP or the the site is down.) I hope that helps. Ziyad. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] shebang question
"john maclean" <[EMAIL PROTECTED]> On Sun, 26 Nov 2006 01:34:28 + wrote: > From what I can tell/remember, the first works in the *nix environment > if python is in your $PATH, ... Actually, no. The first will try to feed the script to the executable "/usr/bin/python". If that doesn't exist (or is not executable) it'll fail. > ...the latter will find python "somehere" on your system by looking at > wher the executables should be. True, assuming there's "/usr/bin/env" on your system (and is executable) and that "python" is found in your "$PATH" (and is executable). The problem is that Python is not installed in the same place on all OSes! Some will install it under "/usr/local", others under "/opt". The idea of "/usr/bin/env" is that it's always installed there (or it should be!). So, you don't need to figure out where is python (or perl, ruby, make, sed, awk, or any other executable that "feeds" on scripts/text files) installed as long as it's in your "$PATH". (Of course, "env" have other uses. As long as I can tell, this is not the intended use of "env". See "info env" for more information, or if you don't have "info" see the manual.) Ziyad. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] [tutor] how to get the fileextention?
On Thu, 2006-07-20 at 11:19 +0300, [EMAIL PROTECTED] wrote: > Hi, > > is this the right (shortest) way to get the file extention > (under MS WIN)? > > > def getext(fname): > ext = fname.split('.').pop() > return ext > > Regards, > Emily > The following maybe a little better: def getExt(fname): return fname.rsplit('.', 1)[1] It uses one method instead of two compared to yours. And in your code there's no need for the ‘ext’ variable, you could use: def getext(fname): return fname.split('.').pop() For more information about ‘str’ objects type the following inside the Python shell: >>> help(str) Ziyad. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] How can I copy files recursively? [Off Topic, AGAIN]
This is “Off Topic” regarding the mailing list! On Mon, 2006-07-10 at 22:57 -0500, Dustin J. Mitchell wrote: (altered by Ziyad) > Richard Querin wrote: > > ... > > I was thinking I could do it easily from the linux command line > > (cp -r copies the subfolders out as well) but I can't figure out > > how to do it. > > ... > Python's not always the best with complex manipulations like that. You > could use os.path.walk, but here's the same thing in bash: > > find $IPODDER_DIR -type f -exec mv \{} $DEST_DIR \; > > Dustin You could use something like this: find SOURCE_DIR -type f -print0 | xargs -0 -i mv {} DIST_DIR Where SOURCE_DIR is the top level directory holding the files and DIST_DIR is the directory you want to move the files to. Make sure there are no conflict in file names otherwise some files will be overwritten! Dustin's version will work perfectly but if there's a lot files it'll exhaust your system because it will create a new process for each file it finds (plus another process for the ‘find’ command itself), while the other version will only create *three* processes only! (One for ‘find’, another for ‘xargs’ and the third is for *one* ‘mv’ move command.) (There's another way by using two piped ‘tar’ commands, but that's overkilling it and the above solution is much more elegant.) A side note: I apologise for the list as it seems I'm only good at posting anything *but* Python related. Ziyad. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Logical Sorting [Off-Topic]
On Sat, 2006-07-08 at 14:39 +0200, Norbert Kaufmann wrote: <زياد بن عبدالعزيز الباتلي wrote: > [...] > > Or use ‘ls -v’. (I said it's “off topic” on the subject, sorry! It > > might escaped you, but ‘ls’ _does_ have a proper sort by version.) > > > > Which OS? > > ~$ uname -mrs > FreeBSD 6.1-STABLE i386 > ~$ ls -v > ls: illegal option -- v > usage: ls [-ABCFGHILPRSTUWZabcdfghiklmnopqrstuwx1] [file ...] > > 'The Open Group Base Specifications' does not list '-v' either. > > Norbert > Almost all Linux flavours a used have that. I'm currently using “Ubuntu 5.10”. Here's the output of “ls --version”: zamb ~ $ ls --version ls (coreutils) 5.2.1 Written by Richard Stallman and David MacKenzie. Copyright (C) 2004 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Ziyad. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Logical Sorting [Off-Topic]
On Fri, 2006-07-07 at 10:09 -0700, Evan Klitzke wrote: > Hi, > > I am trying to sort a list of directories that correspond to kernel > sources under /usr/src/linux. I wrote some code that gets a list like > this: > ['linux-2.6.9-gentoo-r4', 'linux-2.6.16-gentoo-r11/', > 'linux-2.6.16-gentoo-r7/'] > > When I sort the list, I want it to go from oldest (lowest version) to > newest, so the sorted list should look like this: > ['linux-2.6.9-gentoo-r4', 'linux-2.6.16-gentoo-r7/', > 'linux-2.6.16-gentoo-r11/'] > > The problem is that since the built in string comparisons compare > character by character, so the sort puts 2.6.16 before 2.6.9, and -r11 > before -r7. This is obviously not what I want. My question is: are > there any modules or built in methods that will do a logical sort on a > list like this, and sort it the way I want, or will I have to write my > own sorting function? > > -- Evan Klitzke > > P.S. I know that the simplest way is just to use ls to sort by time, > but it is not necessarily true that older kernel versions have an > older time stamp :-) Or use ‘ls -v’. (I said it's “off topic” on the subject, sorry! It might escaped you, but ‘ls’ _does_ have a proper sort by version.) Ziyad. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor