About
Swaroop C H is 29 years of age. He is a coder and startupper. He has previously worked at Yahoo!, Adobe, his own startup and Infibeam.
Views
Support
Personal tools
COLLECTION
Collection
Talk:Python en:Modules
From Notes
Hi, I didn't get the expected output from the "using_sys.py", this was the expected output: The command line arguments are:
using_sys.py we are arguments The PYTHONPATH is ['C:\\tmp', 'C:\\Python30\\python30.zip', 'C:\\Python30\\DLLs', 'C:\\Python30\\lib', 'C:\\Python30\\lib\\plat-win', 'C:\\Python30', 'C:\\Python30\\lib\\site-packages']
And this was the output I got: The command line arguments are: D:\vaei2601\My Documents\Python\Norsk bok\using_sys.py
The PYTHONPATH is ['D:\\vaei2601\\My Documents\\Python\\Norsk bok', 'C:\\Python3
0\\python30.zip', 'C:\\Python30\\DLLs', 'C:\\Python30\\lib', 'C:\\Python30\\lib\
\plat-win', 'C:\\Python30', 'C:\\Python30\\lib\\site-packages']
Was the "We are arguments" supposed to show up at all? Tell me, tell me, tell me, Swaroop!
|
Swaroop said: | On 02:47, 18 October 2008 |
|
Hey Vages, What was the exact command you used to run the program? :) Was it "python using_sys.py we are arguments" or "python using_sys.py" ? | |
| Reply to Swaroop | |
|
Vages said: | On 11:39, 19 October 2008 |
|
Oh, now I see :) Usually, we've just run the programs without suffixing anything, so I've just gotten used to running the programs without reading the detailed instructions about the output. My mistake, but perhaps this should be explained more explicitly. | |
| Reply to Vages | |
No empty string at beginning of PYTHONPATH
Hi, using Python 3.0.1 on Windows, or Python 2.3.4 on Linux, neither first string in the resulting list from sys.path is empty. On both, the first string is the absolute path to the directory where using_sys.py exists.
I understand that the effect is the same, but I wanted to point this out. Could it be a recent change to Python, or a difference in how we have Python configured?
Swaroop says: Here is the output I get with Python 3.0.1 on Windows:
Python 3.0.1 (r301:69561, Feb 13 2009, 20:04:18) [MSC v.1500 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import sys >>> sys.path ['', 'C:\\Windows\\system32\\python30.zip', 'C:\\Python30\\DLLs', 'C:\\Python30\\lib', 'C:\\Python30\\lib\\plat-win', 'C:\\Python30', 'C:\\Python30\\lib\\site-packages'] >>>
Current directory
Also, you might want to clarify the meaning of "current directory". When I think "current directory", I think of the directory I'm currently in within the filesystem. I could be navigating in C:\Windows and run 'python.exe D:\code\using_sys.py'. In that case, the first string in sys.path won't be 'C:\\Windows', it will still be 'D:\\code'.
Swaroop says: I've added a small change for now that should hopefully be clear, but the sentences still need work.
Example for "The from ... import ... statement "
Hi Swaroop, i am doing the spanish translation, and looking the example for "The from ... import ... statement " session i'm thinking it is hard to understand for beginners in python. And it was write on Python 2 (isn't this book of Python 3?) but the other examples are in Python 3.
is this a good example for "The from ... import ... statement"??? a question ;).
And another thing where is the how it works??
Excuse me for the bad english but i am not a good writing ;). Tell me what are you trying to do and i will help you.
I attached the example with few modification (for Python 3 ;))
#!/usr/bin/python3.2 #filename from_import.py from math import * n = int(input("Enter a number: ")) p = [2, 3] cont = 2 a = 5 while(cont < n): b = 0 for i in range(2, a): print(i) if(i <= sqrt(a)): if(a % i == 0): #print (a, "no es primo") b = 1 else: pass if(b != 1): #print (a, "es primo") p = p + [a] cont = cont + 1 a = a + 2 print(p)
- Hi Crisbermud, I'm guessing that I just put in the code there on whether it fits into the program and whether it is beginner enough to be in the chapter or not, you can leave out that section if you believe it is not simple enough for a beginner to understand. -- Swaroop 17:29, 2 December 2011 (IST)