Upcoming SlideShare
×

# جلسه ششم پایتون برای هکر های قانونی دوره مقدماتی پاییز ۹۲- ارائه ۲

222 views
166 views

Published on

در این جلسه به بحث
Namespace
Local and Global variables
پرداختیم
PySec101 Fall 2013 J6E2 By Mohammad Reza Kamalifard
Namespace and Local,Global variables in Python

0 Likes
Statistics
Notes
• Full Name
Comment goes here.

Are you sure you want to Yes No
Your message goes here
• Be the first to comment

• Be the first to like this

Views
Total views
222
On SlideShare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
0
0
Likes
0
Embeds 0
No embeds

No notes for slide

### جلسه ششم پایتون برای هکر های قانونی دوره مقدماتی پاییز ۹۲- ارائه ۲

1. 1. Python for ethical hackers Mohammad reza Kamalifard kamalifard@datasec.ir
2. 2. Python language essentials Module 1: Introduction to Python and Setting up an Environment for Programing Part 8: Global and Local Variables
3. 3. Global and local Variables in Functions >>> def f(): ... print s >>> s = "I hate spam" >>> f()
4. 4. Global and local Variables in Functions >>> def f(): ... print s >>> s = "I hate spam" >>> f() i hate spam >>>
5. 5. Global and local Variables in Functions >>> def f(): ... s = "Me too." ... print s >>> s = "I hate spam." >>> f() >>> print s Me too. I hate spam.
6. 6. Global and local Variables in Functions >>> ... ... >>> >>> >>> def f(): s = "Me too." print s s = "I hate spam." f() print s
7. 7. Global and local Variables in Functions >>> ... ... ... >>> >>> >>> def f(): print s s = "Me too." print s s = "I hate spam." f() print s
8. 8. Global and local Variables in Functions >>> def f(): ... print s ... s = "Me too." ... print s >>> s = "I hate spam." >>> f() >>> print s UnboundLocalError: local variable 's' referenced before assignment
9. 9. Global and local Variables in Functions >>> def f(): ... global s ... print s ... s = "That's clear." ... print s >>> s = "Python is great!" >>> f() >>> print s
10. 10. Global and local Variables in Functions >>> def f(): ... global s ... print s ... s = "That's clear." ... print s >>> s = "Python is great!" >>> f() >>> print s Python is great! That's clear. That's clear.
11. 11. Global and local Variables in Functions >>> def f(): ... s = "I am globally not known" ... print s >>> f() >>> print s
12. 12. Global and local Variables in Functions >>> def f(): ... s = "I am globally not known" ... print s >>> f() >>> print s I am globally not known Traceback (most recent call last): File "global_local3.py", line 6, in <module> print s NameError: name 's' is not defined
13. 13. References SPSE securitytube training by Vivek Ramachandran SANS Python for Pentesters (SEC573) Violent python Security Power Tools python-course.eu ----------------------------http://simeonfranklin.com/blog/2012/jul/1/python-decorators-in-12-steps/ http://www.python-course.eu/global_vs_local_variables.php