Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Programming
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Databases
Mail Systems
openSolaris
Eclipse Documentation
Techotopia.com
Virtuatopia.com
Answertopia.com

How To Guides
Virtualization
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Windows
Problem Solutions
Privacy Policy

  




 

 

Set Literal Values

There are no literal values for sets. A set value is created by using the set or frozenset factory functions. These can be applied to any iterable container, which includes any sequence, and also includes files.

We'll return to “iterable” when we look at the yield statement in Chapter 18, Generators and the yield Statement .

set( iterable ) → set

Transforms the given iterable (sequence, file or set) into a set.

>>> 
set( ("hello", "world", "of", "words", "of", "world") )

set(['world', 'hello', 'words', 'of'])

Note that we provided a six-tuple to the set function, and we got a set with the four unique objects. The set is shown with a list literal, to remind us that a set is mutable.

frozenset ( iterable ) → set

Transforms the given iterable (sequence, file or set) into an immutable frozenset.


 
 
  Published under the terms of the Open Publication License Design by Interspire