This document provides an overview of the Python programming language. It discusses that Python is a popular, object-oriented scripting language that emphasizes code readability. The document summarizes key Python features such as rapid development, automatic memory management, object-oriented programming, and embedding/extending with C. It also outlines common uses of Python and when it may not be suitable.
Python classes in mumbai
best Python classes in mumbai with job assistance.
our features are:
expert guidance by it industry professionals
lowest fees of 5000
practical exposure to handle projects
well equiped lab
after course resume writing guidance
A tour of Python: slides from presentation given in 2012.
[Some slides are not properly rendered in SlideShare: the original is still available at http://www.aleksa.org/2015/04/python-presentation_7.html.]
This fast-paced session starts with an introduction to neural networks and linear regression models, along with a quick view of TensorFlow, followed by some Scala APIs for TensorFlow. You'll also see a simple dockerized image of Scala and TensorFlow code and how to execute the code in that image from the command line. No prior knowledge of NNs, Keras, or TensorFlow is required (but you must be comfortable with Scala).
Python is a high level language focused on readability. The Python community developed the concept of "Pythonic Code", requiring not only semantic correctness, but also conformity to universally acknowledged stylistic criteria.
A pre-requisite to write pythonic code is to write idiomatic code. Using the right idioms is a matter of acquired taste and experience, however, some idioms are quite easy to learn.
This presentation focuses on some of these idioms and other stylistic criteria:
* for vs. while
* iterators, itertools
* code conventions (space invaders)
* avoid default values bugs
* first order functions
* internal/external iterators
* substituting the switch statement
* properties, attributes, read only objects
* named tuples
* duck typings
* bits of metaprogramming
* exception management: LBYL vs. EAFP
A bird's eye view on some programming languages, focusing on concepts like typing, execution model or style. Presented on T3chFest 2016 in Leganés, Madrid, Spain.
Oh Crap, I Forgot (Or Never Learned) C! [CodeMash 2010]Chris Adamson
Abstract: Chances are you code in a language that's either descended from C, inspired by C, or run in an interpreter that itself is written in C. Still... do you actually know how to code in C? Despite its long-standing position as a sort of "lingua franca", an agreed-upon common language, more and more developers are putting together successful, satisfying careers, without ever learning this seminal language. But what if you have to call into C code from your favorite scripting language, or use APIs like OpenGL that are written to be called from C? Many developers find C very challenging, particularly its manual memory-management and other low-level concerns. In this session, we'll show you why you shouldn't be afraid of C, how you can use the skills you already have from the languages you code in today, and how to master structs, enums, typedefs, malloc(), free(), and the rest of C's sharp edges. Examples will be from the point-of-view of the C-skewing iPhone SDK, but will be designed to be broadly applicable and platform-agnostic.
Python classes in mumbai
best Python classes in mumbai with job assistance.
our features are:
expert guidance by it industry professionals
lowest fees of 5000
practical exposure to handle projects
well equiped lab
after course resume writing guidance
A tour of Python: slides from presentation given in 2012.
[Some slides are not properly rendered in SlideShare: the original is still available at http://www.aleksa.org/2015/04/python-presentation_7.html.]
This fast-paced session starts with an introduction to neural networks and linear regression models, along with a quick view of TensorFlow, followed by some Scala APIs for TensorFlow. You'll also see a simple dockerized image of Scala and TensorFlow code and how to execute the code in that image from the command line. No prior knowledge of NNs, Keras, or TensorFlow is required (but you must be comfortable with Scala).
Python is a high level language focused on readability. The Python community developed the concept of "Pythonic Code", requiring not only semantic correctness, but also conformity to universally acknowledged stylistic criteria.
A pre-requisite to write pythonic code is to write idiomatic code. Using the right idioms is a matter of acquired taste and experience, however, some idioms are quite easy to learn.
This presentation focuses on some of these idioms and other stylistic criteria:
* for vs. while
* iterators, itertools
* code conventions (space invaders)
* avoid default values bugs
* first order functions
* internal/external iterators
* substituting the switch statement
* properties, attributes, read only objects
* named tuples
* duck typings
* bits of metaprogramming
* exception management: LBYL vs. EAFP
A bird's eye view on some programming languages, focusing on concepts like typing, execution model or style. Presented on T3chFest 2016 in Leganés, Madrid, Spain.
Oh Crap, I Forgot (Or Never Learned) C! [CodeMash 2010]Chris Adamson
Abstract: Chances are you code in a language that's either descended from C, inspired by C, or run in an interpreter that itself is written in C. Still... do you actually know how to code in C? Despite its long-standing position as a sort of "lingua franca", an agreed-upon common language, more and more developers are putting together successful, satisfying careers, without ever learning this seminal language. But what if you have to call into C code from your favorite scripting language, or use APIs like OpenGL that are written to be called from C? Many developers find C very challenging, particularly its manual memory-management and other low-level concerns. In this session, we'll show you why you shouldn't be afraid of C, how you can use the skills you already have from the languages you code in today, and how to master structs, enums, typedefs, malloc(), free(), and the rest of C's sharp edges. Examples will be from the point-of-view of the C-skewing iPhone SDK, but will be designed to be broadly applicable and platform-agnostic.
Levelwise PageRank with Loop-Based Dead End Handling Strategy : SHORT REPORT ...Subhajit Sahu
Abstract — Levelwise PageRank is an alternative method of PageRank computation which decomposes the input graph into a directed acyclic block-graph of strongly connected components, and processes them in topological order, one level at a time. This enables calculation for ranks in a distributed fashion without per-iteration communication, unlike the standard method where all vertices are processed in each iteration. It however comes with a precondition of the absence of dead ends in the input graph. Here, the native non-distributed performance of Levelwise PageRank was compared against Monolithic PageRank on a CPU as well as a GPU. To ensure a fair comparison, Monolithic PageRank was also performed on a graph where vertices were split by components. Results indicate that Levelwise PageRank is about as fast as Monolithic PageRank on the CPU, but quite a bit slower on the GPU. Slowdown on the GPU is likely caused by a large submission of small workloads, and expected to be non-issue when the computation is performed on massive graphs.
Data Centers - Striving Within A Narrow Range - Research Report - MCG - May 2...pchutichetpong
M Capital Group (“MCG”) expects to see demand and the changing evolution of supply, facilitated through institutional investment rotation out of offices and into work from home (“WFH”), while the ever-expanding need for data storage as global internet usage expands, with experts predicting 5.3 billion users by 2023. These market factors will be underpinned by technological changes, such as progressing cloud services and edge sites, allowing the industry to see strong expected annual growth of 13% over the next 4 years.
Whilst competitive headwinds remain, represented through the recent second bankruptcy filing of Sungard, which blames “COVID-19 and other macroeconomic trends including delayed customer spending decisions, insourcing and reductions in IT spending, energy inflation and reduction in demand for certain services”, the industry has seen key adjustments, where MCG believes that engineering cost management and technological innovation will be paramount to success.
MCG reports that the more favorable market conditions expected over the next few years, helped by the winding down of pandemic restrictions and a hybrid working environment will be driving market momentum forward. The continuous injection of capital by alternative investment firms, as well as the growing infrastructural investment from cloud service providers and social media companies, whose revenues are expected to grow over 3.6x larger by value in 2026, will likely help propel center provision and innovation. These factors paint a promising picture for the industry players that offset rising input costs and adapt to new technologies.
According to M Capital Group: “Specifically, the long-term cost-saving opportunities available from the rise of remote managing will likely aid value growth for the industry. Through margin optimization and further availability of capital for reinvestment, strong players will maintain their competitive foothold, while weaker players exit the market to balance supply and demand.”
Techniques to optimize the pagerank algorithm usually fall in two categories. One is to try reducing the work per iteration, and the other is to try reducing the number of iterations. These goals are often at odds with one another. Skipping computation on vertices which have already converged has the potential to save iteration time. Skipping in-identical vertices, with the same in-links, helps reduce duplicate computations and thus could help reduce iteration time. Road networks often have chains which can be short-circuited before pagerank computation to improve performance. Final ranks of chain nodes can be easily calculated. This could reduce both the iteration time, and the number of iterations. If a graph has no dangling nodes, pagerank of each strongly connected component can be computed in topological order. This could help reduce the iteration time, no. of iterations, and also enable multi-iteration concurrency in pagerank computation. The combination of all of the above methods is the STICD algorithm. [sticd] For dynamic graphs, unchanged components whose ranks are unaffected can be skipped altogether.
Explore our comprehensive data analysis project presentation on predicting product ad campaign performance. Learn how data-driven insights can optimize your marketing strategies and enhance campaign effectiveness. Perfect for professionals and students looking to understand the power of data analysis in advertising. for more details visit: https://bostoninstituteofanalytics.org/data-science-and-artificial-intelligence/
1. Python
Henning Schulzrinne
Department of Computer Science
Columbia University
(based on tutorial by Guido van
Rossum)
NAME-SONAM KUMARI
BRANCH-ECE
ROLL NO..-19EEBEC016
2. Introduction
Most recent popular
(scripting/extension) language
although origin ~1991
heritage: teaching language (ABC)
Tcl: shell
perl: string (regex) processing
object-oriented
rather than add-on (OOTcl)
Advanced Programming
Spring 2002
3. Python philosophy
Coherence
not hard to read, write and maintain
power
scope
rapid development + large systems
objects
integration
hybrid systems
Advanced Programming
Spring 2002
4. Python features
no compiling or linking rapid development cycle
no type declarations simpler, shorter, more flexible
automatic memory management garbage collection
high-level data types and operations fast development
object-oriented programming code structuring and reuse, C++
embedding and extending in C mixed language systems
classes, modules, exceptions "programming-in-the-large" support
dynamic loading of C modules simplified extensions, smaller binaries
dynamic reloading of C modules programs can be modified without
stopping
Lutz, Programming Python
Advanced Programming
Spring 2002
5. Python features
universal "first-class" object model fewer restrictions and rules
run-time program construction handles unforeseen needs, end-user
coding
interactive, dynamic nature incremental development and testing
access to interpreter information metaprogramming, introspective
objects
wide portability cross-platform programming without
ports
compilation to portable byte-code execution speed, protecting source
code
built-in interfaces to external services system tools, GUIs, persistence,
databases, etc.
Lutz, Programming Python
Advanced Programming
Spring 2002
6. Python
elements from C++, Modula-3
(modules), ABC, Icon (slicing)
same family as Perl, Tcl, Scheme, REXX,
BASIC dialects
Advanced Programming
Spring 2002
7. Uses of Python
shell tools
system admin tools, command line programs
extension-language work
rapid prototyping and development
language-based modules
instead of special-purpose parsers
graphical user interfaces
database access
distributed programming
Internet scripting
Advanced Programming
Spring 2002
8. What not to use Python (and
kin) for
most scripting languages share these
not as efficient as C
but sometimes better built-in algorithms
(e.g., hashing and sorting)
delayed error notification
lack of profiling tools
Advanced Programming
Spring 2002
9. Using python
/usr/local/bin/python
#! /usr/bin/env python
interactive use
Python 1.6 (#1, Sep 24 2000, 20:40:45) [GCC 2.95.1 19990816 (release)] on sunos5
Copyright (c) 1995-2000 Corporation for National Research Initiatives.
All Rights Reserved.
Copyright (c) 1991-1995 Stichting Mathematisch Centrum, Amsterdam.
All Rights Reserved.
>>>
python –c command [arg] ...
python –i script
read script first, then interactive
Advanced Programming
Spring 2002
10. Python structure
modules: Python source files or C extensions
import, top-level via from, reload
statements
control flow
create objects
indentation matters – instead of {}
objects
everything is an object
automatically reclaimed when no longer needed
Advanced Programming
Spring 2002
11. First example
#!/usr/local/bin/python
# import systems module
import sys
marker = '::::::'
for name in sys.argv[1:]:
input = open(name, 'r')
print marker + name
print input.read()
Advanced Programming
Spring 2002
12. Basic operations
Assignment:
size = 40
a = b = c = 3
Numbers
integer, float
complex numbers: 1j+3, abs(z)
Strings
'hello world', 'it's hot'
"bye world"
continuation via or use """ long text """"
Advanced Programming
Spring 2002
13. String operations
concatenate with + or neighbors
word = 'Help' + x
word = 'Help' 'a'
subscripting of strings
'Hello'[2] 'l'
slice: 'Hello'[1:2] 'el'
word[-1] last character
len(word) 5
immutable: cannot assign to subscript
Advanced Programming
Spring 2002
14. Lists
lists can be heterogeneous
a = ['spam', 'eggs', 100, 1234, 2*2]
Lists can be indexed and sliced:
a[0] spam
a[:2] ['spam', 'eggs']
Lists can be manipulated
a[2] = a[2] + 23
a[0:2] = [1,12]
a[0:0] = []
len(a) 5
Advanced Programming
Spring 2002
15. Basic programming
a,b = 0, 1
# non-zero = true
while b < 10:
# formatted output, without n
print b,
# multiple assignment
a,b = b, a+b
Advanced Programming
Spring 2002
16. Control flow: if
x = int(raw_input("Please enter #:"))
if x < 0:
x = 0
print 'Negative changed to zero'
elif x == 0:
print 'Zero'
elif x == 1:
print 'Single'
else:
print 'More'
no case statement
Advanced Programming
Spring 2002
17. Control flow: for
a = ['cat', 'window', 'defenestrate']
for x in a:
print x, len(x)
no arithmetic progression, but
range(10) [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
for i in range(len(a)):
print i, a[i]
do not modify the sequence being iterated
over
Advanced Programming
Spring 2002
18. Loops: break, continue, else
break and continue like C
else after loop exhaustion
for n in range(2,10):
for x in range(2,n):
if n % x == 0:
print n, 'equals', x, '*', n/x
break
else:
# loop fell through without finding a factor
print n, 'is prime'
Advanced Programming
Spring 2002
19. Do nothing
pass does nothing
syntactic filler
while 1:
pass
Advanced Programming
Spring 2002
20. Defining functions
def fib(n):
"""Print a Fibonacci series up to n."""
a, b = 0, 1
while b < n:
print b,
a, b = b, a+b
>>> fib(2000)
First line is docstring
first look for variables in local, then global
need global to assign global variables
Advanced Programming
Spring 2002
21. Functions: default argument
values
def ask_ok(prompt, retries=4,
complaint='Yes or no, please!'):
while 1:
ok = raw_input(prompt)
if ok in ('y', 'ye', 'yes'): return 1
if ok in ('n', 'no'): return 0
retries = retries - 1
if retries < 0: raise IOError,
'refusenik error'
print complaint
>>> ask_ok('Really?')
Advanced Programming
Spring 2002
22. Keyword arguments
last arguments can be given as keywords
def parrot(voltage, state='a stiff', action='voom',
type='Norwegian blue'):
print "-- This parrot wouldn't", action,
print "if you put", voltage, "Volts through it."
print "Lovely plumage, the ", type
print "-- It's", state, "!"
parrot(1000)
parrot(action='VOOOM', voltage=100000)
Advanced Programming
Spring 2002
23. Lambda forms
anonymous functions
may not work in older versions
def make_incrementor(n):
return lambda x: x + n
f = make_incrementor(42)
f(0)
f(1)
Advanced Programming
Spring 2002
24. List methods
append(x)
extend(L)
append all items in list (like Tcl lappend)
insert(i,x)
remove(x)
pop([i]), pop()
create stack (FIFO), or queue (LIFO) pop(0)
index(x)
return the index for value x
Advanced Programming
Spring 2002
25. List methods
count(x)
how many times x appears in list
sort()
sort items in place
reverse()
reverse list
Advanced Programming
Spring 2002
26. Functional programming tools
filter(function, sequence)
def f(x): return x%2 != 0 and x%3 0
filter(f, range(2,25))
map(function, sequence)
call function for each item
return list of return values
reduce(function, sequence)
return a single value
call binary function on the first two items
then on the result and next item
iterate
Advanced Programming
Spring 2002
27. List comprehensions (2.0)
Create lists without map(),
filter(), lambda
= expression followed by for clause +
zero or more for or of clauses
>>> vec = [2,4,6]
>>> [3*x for x in vec]
[6, 12, 18]
>>> [{x: x**2} for x in vec}
[{2: 4}, {4: 16}, {6: 36}]
Advanced Programming
Spring 2002
28. List comprehensions
cross products:
>>> vec1 = [2,4,6]
>>> vec2 = [4,3,-9]
>>> [x*y for x in vec1 for y in vec2]
[8,6,-18, 16,12,-36, 24,18,-54]
>>> [x+y for x in vec1 and y in vec2]
[6,5,-7,8,7,-5,10,9,-3]
>>> [vec1[i]*vec2[i] for i in
range(len(vec1))]
[8,12,-54]
Advanced Programming
Spring 2002
29. List comprehensions
can also use if:
>>> [3*x for x in vec if x > 3]
[12, 18]
>>> [3*x for x in vec if x < 2]
[]
Advanced Programming
Spring 2002
30. del – removing list items
remove by index, not value
remove slices from list (rather than by
assigning an empty list)
>>> a = [-1,1,66.6,333,333,1234.5]
>>> del a[0]
>>> a
[1,66.6,333,333,1234.5]
>>> del a[2:4]
>>> a
[1,66.6,1234.5]
Advanced Programming
Spring 2002
31. Tuples and sequences
lists, strings, tuples: examples of
sequence type
tuple = values separated by commas
>>> t = 123, 543, 'bar'
>>> t[0]
123
>>> t
(123, 543, 'bar')
Advanced Programming
Spring 2002
32. Tuples
Tuples may be nested
>>> u = t, (1,2)
>>> u
((123, 542, 'bar'), (1,2))
kind of like structs, but no element names:
(x,y) coordinates
database records
like strings, immutable can't assign to
individual items
Advanced Programming
Spring 2002
34. Tuples
sequence unpacking distribute
elements across variables
>>> t = 123, 543, 'bar'
>>> x, y, z = t
>>> x
123
packing always creates tuple
unpacking works for any sequence
Advanced Programming
Spring 2002
35. Dictionaries
like Tcl or awk associative arrays
indexed by keys
keys are any immutable type: e.g., tuples
but not lists (mutable!)
uses 'key: value' notation
>>> tel = {'hgs' : 7042, 'lennox': 7018}
>>> tel['cs'] = 7000
>>> tel
Advanced Programming
Spring 2002
36. Dictionaries
no particular order
delete elements with del
>>> del tel['foo']
keys() method unsorted list of keys
>>> tel.keys()
['cs', 'lennox', 'hgs']
use has_key() to check for existence
>>> tel.has_key('foo')
0
Advanced Programming
Spring 2002
37. Conditions
can check for sequence membership with is
and is not:
>>> if (4 in vec):
... print '4 is'
chained comparisons: a less than b AND b
equals c:
a < b == c
and and or are short-circuit operators:
evaluated from left to right
stop evaluation as soon as outcome clear
Advanced Programming
Spring 2002
38. Conditions
Can assign comparison to variable:
>>> s1,s2,s3='', 'foo', 'bar'
>>> non_null = s1 or s2 or s3
>>> non_null
foo
Unlike C, no assignment within
expression
Advanced Programming
Spring 2002
39. Comparing sequences
unlike C, can compare sequences (lists,
tuples, ...)
lexicographical comparison:
compare first; if different outcome
continue recursively
subsequences are smaller
strings use ASCII comparison
can compare objects of different type, but
by type name (list < string < tuple)
Advanced Programming
Spring 2002
41. Modules
collection of functions and variables,
typically in scripts
definitions can be imported
file name is module name + .py
e.g., create module fibo.py
def fib(n): # write Fib. series up to n
...
def fib2(n): # return Fib. series up to n
Advanced Programming
Spring 2002
42. Modules
import module:
import fibo
Use modules via "name space":
>>> fibo.fib(1000)
>>> fibo.__name__
'fibo'
can give it a local name:
>>> fib = fibo.fib
>>> fib(500)
Advanced Programming
Spring 2002
43. Modules
function definition + executable statements
executed only when module is imported
modules have private symbol tables
avoids name clash for global variables
accessible as module.globalname
can import into name space:
>>> from fibo import fib, fib2
>>> fib(500)
can import all names defined by module:
>>> from fibo import *
Advanced Programming
Spring 2002
44. Module search path
current directory
list of directories specified in PYTHONPATH
environment variable
uses installation-default if not defined, e.g.,
.:/usr/local/lib/python
uses sys.path
>>> import sys
>>> sys.path
['', 'C:PROGRA~1Python2.2', 'C:Program
FilesPython2.2DLLs', 'C:Program
FilesPython2.2lib', 'C:Program
FilesPython2.2liblib-tk', 'C:Program
FilesPython2.2', 'C:Program FilesPython2.2libsite-
packages']
Advanced Programming
Spring 2002
45. Compiled Python files
include byte-compiled version of module if
there exists fibo.pyc in same directory as
fibo.py
only if creation time of fibo.pyc matches
fibo.py
automatically write compiled file, if possible
platform independent
doesn't run any faster, but loads faster
can have only .pyc file hide source
Advanced Programming
Spring 2002
46. Standard modules
system-dependent list
always sys module
>>> import sys
>>> sys.p1
'>>> '
>>> sys.p2
'... '
>>> sys.path.append('/some/directory')
Advanced Programming
Spring 2002
48. Classes
mixture of C++ and Modula-3
multiple base classes
derived class can override any methods of its
base class(es)
method can call the method of a base class
with the same name
objects have private data
C++ terms:
all class members are public
all member functions are virtual
no constructors or destructors (not needed)
Advanced Programming
Spring 2002
49. Classes
classes (and data types) are objects
built-in types cannot be used as base
classes by user
arithmetic operators, subscripting can
be redefined for class instances (like
C++, unlike Java)
Advanced Programming
Spring 2002
51. Namespaces
mapping from name to object:
built-in names (abs())
global names in module
local names in function invocation
attributes = any following a dot
z.real, z.imag
attributes read-only or writable
module attributes are writeable
Advanced Programming
Spring 2002
52. Namespaces
scope = textual region of Python program
where a namespace is directly accessible
(without dot)
innermost scope (first) = local names
middle scope = current module's global names
outermost scope (last) = built-in names
assignments always affect innermost scope
don't copy, just create name bindings to objects
global indicates name is in global scope
Advanced Programming
Spring 2002
53. Class objects
obj.name references (plus module!):
class MyClass:
"A simple example class"
i = 123
def f(self):
return 'hello world'
>>> MyClass.i
123
MyClass.f is method object
Advanced Programming
Spring 2002
54. Class objects
class instantiation:
>>> x = MyClass()
>>> x.f()
'hello world'
creates new instance of class
note x = MyClass vs. x = MyClass()
___init__() special method for
initialization of object
def __init__(self,realpart,imagpart):
self.r = realpart
self.i = imagpart
Advanced Programming
Spring 2002
55. Instance objects
attribute references
data attributes (C++/Java data
members)
created dynamically
x.counter = 1
while x.counter < 10:
x.counter = x.counter * 2
print x.counter
del x.counter
Advanced Programming
Spring 2002
56. Method objects
Called immediately:
x.f()
can be referenced:
xf = x.f
while 1:
print xf()
object is passed as first argument of
function 'self'
x.f() is equivalent to MyClass.f(x)
Advanced Programming
Spring 2002
57. Notes on classes
Data attributes override method
attributes with the same name
no real hiding not usable to
implement pure abstract data types
clients (users) of an object can add
data attributes
first argument of method usually called
self
'self' has no special meaning (cf. Java)
Advanced Programming
Spring 2002
58. Another example
bag.py
class Bag:
def __init__(self):
self.data = []
def add(self, x):
self.data.append(x)
def addtwice(self,x):
self.add(x)
self.add(x)
Advanced Programming
Spring 2002
59. Another example, cont'd.
invoke:
>>> from bag import *
>>> l = Bag()
>>> l.add('first')
>>> l.add('second')
>>> l.data
['first', 'second']
Advanced Programming
Spring 2002
62. Private variables
No real support, but textual
replacement (name mangling)
__var is replaced by
_classname_var
prevents only accidental modification,
not true protection
Advanced Programming
Spring 2002
63. ~ C structs
Empty class definition:
class Employee:
pass
john = Employee()
john.name = 'John Doe'
john.dept = 'CS'
john.salary = 1000
Advanced Programming
Spring 2002
64. Exceptions
syntax (parsing) errors
while 1 print 'Hello World'
File "<stdin>", line 1
while 1 print 'Hello World'
^
SyntaxError: invalid syntax
exceptions
run-time errors
e.g., ZeroDivisionError,
NameError, TypeError
Advanced Programming
Spring 2002
65. Handling exceptions
while 1:
try:
x = int(raw_input("Please enter a number: "))
break
except ValueError:
print "Not a valid number"
First, execute try clause
if no exception, skip except clause
if exception, skip rest of try clause and use except
clause
if no matching exception, attempt outer try
statement
Advanced Programming
Spring 2002
66. Handling exceptions
try.py
import sys
for arg in sys.argv[1:]:
try:
f = open(arg, 'r')
except IOError:
print 'cannot open', arg
else:
print arg, 'lines:',
len(f.readlines())
f.close
e.g., as python try.py *.py
Advanced Programming
Spring 2002