This is O.R.Senthil Kumaran's blogspot on programming and technical things. The title is a line from "Zen of Python".
Download Picasaweb Album on Linux
Direct download to Picasa does not work. It works on Windows.
James Gosling on Development of Java
James Gosling:So long as they do that. The development of Java is not an inexpensive thing. It takes a fair amount of funding. It's not just about writing code. Learning the code is two or three percent of the expense. You're shipping fifteen million copies a week, just the bandwith is horrible. The QA when you have to worry about something that has thirty issues. When you've got everything, every stock exchange, every phone company on the planet. Their security depends on Java. So it's not a causual piece of testing.
You know, when it comes to open source contributions, our history with contributions over the years have been kinda snarky. We'd get lost of people sending code and fixes. But on average, we'd get a submission that fixed the bug but it caused three or four more. And it probably didn't fix the bug for everybody. It probably only fixed the bug for their one case. And trying to get people in the community to actually think about the whole code base and not just their particular issue today. Doing one line of change means an immense amount of testing.
Most open source projects are way too casual for that. Sometimes when you get bugs that are potential security issues, you have to move fast, you have to put immense resources on getting it done. Maybe it's just one engineer fixing one character in one line, but then testing it and making sure you didn't introduce a bug. The harder stuff is if you have a bug, there are probably people out there who have worked around that bug, so how many of the workarounds are you going to break. And when you've got nine or ten million in the developer community you have enormous applications, trivial fixes are not trivial. And open source projects, the way the average open source projects are constituted. IT's easy to get people to do the fun stuff. It's hard to get people to do the hard stuff.
Like QAing the math libraries. Like doing QA on sine and cosine, you absolutely have to have a PHd in Mathematics. Sine and cosine: it sounds really simple, but there is unbelievable amount of depths of subtlety in there. There are extraordinarily few people on the planet qualified to QA that type of stuff.
http://www.basementcoders.com/transcripts/James_Gosling_Transcript.html
Quote HTML Function in python
def _quote_html(html):
return html.replace("&", "&").replace("<", "<").replace(">", ">")
-bash: /bin/ls: Argument list too long
ls *-output.logon directory containing 7000 files fails with the error
-bash: /bin/ls: Argument list too long
The best way to go about with this is:
find . -name '*-output.log' | xargs ls -l
using imapfilter
I struggled a bit to use imapfilter to delete the mails at the server.
The following was configuration
--------------
-- Options --
---------------
options.timeout = 120
options.subscribe = true
----------------
-- Accounts --
----------------
-- Connects to "imap1.mail.server", as user "user1" with "secret1" as
-- password.
account1 = IMAP {
server = 'myserver.com',
port = 993,
username = 'username',
password = 'password.',
ssl = 'tls1',
}
results = account1.INBOX:contain_subject('Subject')
-- Delete messages. This DOES NOT Work.
-- results:delete_messages()
-- This Works
account1.INBOX:delete_messages(results)
urlopen with multiple retries
def _retry_thrice(func, exc, *args, **kwargs):
for i in range(3):
try:
return func(*args, **kwargs)
except exc, last_exc:
continue
except:
raise
raise last_exc
def _wrap_with_retry_thrice(func, exc):
def wrapped(*args, **kwargs):
return _retry_thrice(func, exc, *args, **kwargs)
return wrapped
# Connecting to remote hosts is flaky. Make it more robust by retrying
# the connection several times.
_urlopen_with_retry = _wrap_with_retry_thrice(urllib2.urlopen, urllib2.URLError)
Constructing a command for subprocess execution
Consider the following command and see how shlex module makes it more suitable for subprocess.Popen
/bin/vikings -input eggs.txt -output "spam spam.txt" -cmd "echo '$MONEY'"
import shlex
cmd = """/bin/vikings -input eggs.txt -output "spam spam.txt" -cmd "echo '$MONEY'" """
list_cmd1 = cmd.split(' ')
list_cmd2 = shlex.split(cmd)
print list_cmd1
print list_cmd2
['/bin/vikings', '-input', 'eggs.txt', '-output', 'spam spam.txt', '-cmd', "echo '$MONEY'"]
Least used Modules from Python Standard Library
I (Geremy Condra) ran some statistics (over pypi) on the number of
times modules out of the stdlib got imported a few months ago and came
up with a reasonably comprehensive list of the least-used things in
the stdlib. For the record, since I wound up parsing import statements
and know some garbage data got in, its reasonable to assume that a few
otherwise valid imports aren't recorded here. But enough with the
disclaimers.
0 AL
0 ColorPicker
0 DEVICE
0 FL
0 FrameWork
0 Nav
0 PixMapWrapper
0 SUNAUDIODEV
0 aepack
0 aetypes
0 al
0 applesingle
0 autoGIL
0 buildtools
0 cd
0 cfmfile
0 dbhash
0 dl
0 dummy_threading
0 findertools
0 flp
0 fm
0 fpectl
0 gensuitemodule
0 icopen
0 imageop
0 imgfile
0 jpeg
0 macerrors
0 macostools
0 macresource
0 nis
0 posixfile
0 spwd
0 sunaudiodev
0 symtable
0 videoreader
0 winsound
1 Tix
1 audioop
2 ic
3 Bastion
3 binhex
3 dumbdbm
3 dummy_thread
3 fractions
3 future_builtins
3 mailcap
3 ossaudiodev
3 tabnanny
3 xdrlib
4 ScrolledText
4 macpath
4 stringprep
5 DocXMLRPCServer
5 GL
5 aifc
5 mimify
5 sunau
6 fl
6 pickletools
6 statvfs
6 turtle
7 W
8 codeop
8 multifile
8 nntplib
8 poplib
8 sndhdr
9 EasyDialogs
9 pipes
9 pyclbr
10 dbm
10 gdbm
10 imputil
11 MiniAEFrame
11 fpformat
11 numbers
14 CGIHTTPServer
14 pty
16 rexec
18 netrc
19 msvcrt
19 uu
20 rlcompleter
21 compileall
22 tty
24 lib2to3
24 mutex
25 chunk
25 mhlib
27 whichdb
28 robotparser
29 ssl
30 dircache
32 gl
33 runpy
34 posix
36 aetools
36 wave
37 termios
42 bdb
44 imaplib
46 ast
47 bsddb
47 imghdr
50 crypt
50 smtpd
53 Carbon
57 MimeWriter
57 msilib
60 cmath
66 filecmp
67 syslog
68 MacOS
73 cProfile
74 asynchat
74 repr
75 ftplib
76 htmllib
83 abc
91 quopri
93 pkgutil
98 anydbm
98 telnetlib
99 trace
102 formatter
104 __main__
104 readline
105 colorsys
110 _winreg
111 curses
113 plistlib
115 modulefinder
116 UserString
121 cookielib
125 mailbox
126 cgitb
128 bz2
128 sched
134 io
146 mimetools
147 pydoc
148 SimpleXMLRPCServer
154 mmap
155 user
156 site
157 symbol
159 zipimport
166 pstats
172 fileinput
173 encodings
179 py_compile
180 SimpleHTTPServer
181 profile
183 cmd
198 Tkinter
200 fcntl
206 copy_reg
225 linecache
226 hotshot
234 multiprocessing
262 dis
273 UserList
273 resource
287 SocketServer
289 shelve
297 sqlite3
317 grp
322 asyncore
335 timeit
339 keyword
345 sgmllib
363 token
367 test
383 parser
386 shlex
421 wsgiref
451 contextlib
458 unicodedata
471 tokenize
472 pwd
487 webbrowser
526 hmac
529 heapq
542 platform
573 gettext
594 pdb
597 popen2
607 json
608 marshal
619 smtplib
621 bisect
637 difflib
647 commands
657 BaseHTTPServer
677 Cookie
688 locale
695 zlib
708 HTMLParser
710 code
721 rfc822
748 compiler
759 gzip
759 select
771 ctypes
788 gc
796 binascii
812 getpass
822 __builtin__
854 htmlentitydefs
857 tarfile
869 decimal
872 xmlrpclib
903 csv
933 atexit
943 functools
946 exceptions
976 array
979 sha
1044 thread
1056 calendar
1064 zipfile
1070 UserDict
1078 new
1102 uuid
1148 Queue
1159 sets
1172 signal
1213 hashlib
1242 getopt
1276 email
1310 imp
1321 fnmatch
1328 mimetypes
1348 collections
1442 httplib
1469 cPickle
1505 md5
1614 weakref
1618 textwrap
1654 pickle
1722 errno
1729 stat
2020 pprint
2060 struct
2389 codecs
2391 ConfigParser
2406 operator
2578 math
2626 base64
2925 inspect
3013 cgi
3105 itertools
3250 xml
3318 glob
3402 __future__
3505 warnings
3549 socket
3722 urlparse
4014 traceback
4142 subprocess
4194 threading
4198 cStringIO
4224 string
4501 copy
4696 random
5088 shutil
5392 tempfile
5426 doctest
5642 optparse
5913 types
6185 StringIO
6522 urllib
7346 distutils
7930 datetime
8416 urllib2
9567 logging
9906 time
13019 re
14714 unittest
18334 sys
27468 os