Forum     

Go Back   Digit Technology Discussion Forum > Software > Programming
Register FAQ Calendar Mark Forums Read

Programming The destination for developers - C, C++, Java, Python and the lot


Reply
 
LinkBack Thread Tools Display Modes
Old 23-08-2011, 06:58 PM   #1 (permalink)
Right Off the Assembly Line
 
Join Date: May 2011
Posts: 6
Default need help in python


When I run the code:
>>>i=5
>>>def f(arg=i):
print(arg)

>>>i=6
>>>f()
It print 5.Why is this so??
ankurankan is offline   Reply With Quote
Advertisements. Register and be a member of the community to get rid of them.
Advertisement

Old 24-08-2011, 07:31 PM   #2 (permalink)
Manchester United <3
 
Ishu Gupta's Avatar
 
Join Date: Oct 2010
Location: Noida
Posts: 2,122
Default Re: need help in python

In the second line, its read as def f(arg=5):.
If you use f(i), it'll print 6.
__________________
i5 2500k 4.4GHz @ 1.25v | CM Hyper 212 Evo | HD 3000 @ 1.5GHz | Asus P8Z68-V Gen 3
2x4GB DDR3 1600MHz CL9 | 160GB 7200rpm + 160GB 5400rpm | W7 x64
CM690 II USB3 | Corsair TX750W V2 | APC 1.1KVa | Dell U2312HM + Sansui V8 19"
Razer DA Black + Razer Goliathus | XBox360 wired x2
Senns HD201 | PSP Slim 8GB MSPD | N5800XM 8GB MSD | Speedtest
Ishu Gupta is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


 
Latest Threads
- by Charan
- by Sarath
- by clmlbx

Advertisement




All times are GMT +5.5. The time now is 12:33 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.

Search Engine Optimization by vBSEO 3.3.2