to check if the given path exists
path = '/home/john/temp'
os.path.exists(path)
#this returns false if path doesn't exist or if the path is a broken symbolic link
to check if the given path is a directory
dirname = '/home/john/python'
os.path.isdir(dirname)
to check if the given path is a file
filename = dirname + 'main.py'
os.path.isfile(filename)
to check if the given path is symbolic link
symlink = dirname + 'some_sym_link'
os.path.islink(symli...
A common use of member functions is for encapsulation, using an accessor (commonly known as a getter) and a mutator (commonly known as a setter) instead of accessing fields directly.
class Encapsulator {
int encapsulated;
public:
int get_encapsulated() const { return encapsulated; }...
configuration EnableIISFeature
{
node localhost
{
WindowsFeature IIS
{
Ensure = “Present”
Name = “Web-Server”
}
}
}
If you run this configuration in Powershell (EnableIISFeature), it will produce a localho...
#!/usr/bin/env python
"""
An annotated simple socket client example in python.
WARNING: This example doesn't show a very important aspect of
TCP - TCP doesn't preserve message boundaries. Please refer
to http://blog.stephencleary.com/2009/04/message-framing.html
before adaptin...
Getting the effective execution policy for the current session:
PS> Get-ExecutionPolicy
RemoteSigned
List all effective execution policies for the current session:
PS> Get-ExecutionPolicy -List
Scope ExecutionPolicy
----- ---------------
MachinePolicy Undefined...
Unity networking provides the High Level API (HLA) to handle network communications abstracting from low level implementations.
In this example we will see how to create a Server that can communicate with one or multiple clients.
The HLA allows us to easily serialize a class and send objects of ...
Adding tags to "describe" or "it" blocks allows you to run only those examples with a given tag. Use the --tag (or -t) option to run examples that match a specified tag. The tag can be a simple name or a name:value pair.
If a simple name is supplied, only examples with :name...
If you are only adding new rows in your RDBMS (not updating existing data)
You need two additional parameters:
--check-column : A column name that should be checked for newly appended data. Integer would be a suitable data type for this column.
--last-value : The last value that successfully im...
The following examples use HAL to express HATEOAS, and make use of:
CURIE (Compact URI): used to provide links to API documentation
URI templates: URI that includes parameters that must be substituted before the URI is resolved
Get blog 123
Request
GET https://example.com/api/v1.2/blogs/123...
Some programmers think that it is a good idea to save space by using a null to represent an empty array or collection. While it is true that you can save a small amount of space, the flipside is that it makes your code more complicated, and more fragile. Compare these two versions of a method for ...
All arrays implement the non-generic IList interface (and hence non-generic ICollection and IEnumerable base interfaces).
More importantly, one-dimensional arrays implement the IList<> and IReadOnlyList<> generic interfaces (and their base interfaces) for the type of data that they cont...
Rust's coherence rule requires that either the trait or the type for which you are implementing the trait must be defined in the same crate as the impl, so it is not possible to implement Serialize and Deserialize for a type in a different crate directly. The newtype pattern and Deref coercion provi...
Because data is sensitive when dealt with between two threads (think concurrent read and concurrent write can conflict with one another, causing race conditions), a set of unique objects were made in order to facilitate the passing of data back and forth between threads. Any truly atomic operation c...