Displaying keyword search results 1 - 4
Created by Dr. Xi on June 06, 2009 18:31:44 Last update: June 25, 2012 12:37:35
You can use the system call from the os module to execute an external program:
>>> import os >>> os.system(the_command_line_st...However, the path to the executable contains a space character, the system call treats the strings after the first space as arguments, causing an error. Python doc recommends the use of the subprocess module: The subprocess module provides more powerful facilities for spawning new processes and retrieving their results; using that module is preferable to using this function. For example, using wget to get the google home page:
>>> from subprocess import Popen, PIPE >>> (out...or
>>> import subprocess >>> subprocess.call(['cur...
Created by freyo on September 07, 2011 16:46:14 Last update: September 07, 2011 19:23:00
The Android unit test framework is based on JUnit 3 , not JUnit 4. Test cases have to extend junit.framework.TestCase or a subclass (such as android.test.InstrumentationTestCase ). Tests are identified by public methods whose name starts with test , not methods annotated with @Test (as in JUnit 4). An Android test suite is packaged as an APK, just like the application being tested. To create a test package, first you need to identify the application package it is testing. Google suggests to put the test package source in a directory named tests/ alongside the src/ directory of the main application. At runtime, Android instrumentation loads both the test package and the application under test into the same process. Therefore, the tests can invoke methods on...
Created by Dr. Xi on April 26, 2011 20:12:01 Last update: April 28, 2011 15:28:12
An XML schema is a definition of XML files, in XML. It plays the same role as old-time DTDs. Overall, an XML schema file looks like this:
<schema attributeFormDefault = (qualified | u...The attribute meanings: targetNamespace : The name space targeted by the current schema definition. It can be any URI. id and version : For user convenience, the W3C spec defines no semantics for them. xml:lang : Natural language identifier defined by RFC 3306 . attributeFormDefault and elementFormDefault : Set default values for the form attribute for attribute and element declarations. blockDefault and finalDefault : Set default values for the block and final attributes for attribute and element declarations. The W3C defined some built-in datatypes . Examples of primitive datatypes are: string ,...
Created by Dr. Xi on March 02, 2011 11:39:18 Last update: March 09, 2011 12:19:30
Some peculiarities about Java PrintWriter: PrintWriter never throws any exceptions. From JavaDoc : Methods in this class never throw I/O exceptions, although some of its constructors may. The client may inquire as to whether any errors have occurred by invoking checkError(). When error occurs, you'll never know anything more than that it occured, because checkError returns boolean. When a character is out of the range of the character encoding of the PrintWriter, it prints a question mark (?). But this is not an error. Test code:
import java.io.*; public class TestPrintWri...Latin1 test result:
java TestPrintWriter iso-8859-1 | od -bc 000000...UTF-8 test result:
java TestPrintWriter utf-8 | od -bc 0000000 141...Also, the constructor throws a FileNotFoundException when you try to write to a...