Talk:Python Programming/Creating Python Programs
Add topicend parameter?
[edit source]print ("Hello, world!", end="") doesn't work in my Python 2.5.2 --Vanuan (talk) 22:06, 11 March 2009 (UTC)
- Actually, there's no trace of any "end" command or method for Python, neither in my interpretor nor in Google. I think about removing this paragraph, which function should be replaced by a module one :
import re
>>> text = "Hello, world!"
>>> text = re.sub("!","",text)
>>> print(text)
Hello, world
>>>
JackPotte (talk) 23:20, 24 May 2009 (UTC)
I suppose you *could* eliminate any mention of how to continue on the same line, but that would make it impossible for a novice programmer to have enough information to complete one of the exercises on this page: "Re-write the original program to use two print statements: one for "Hello" and one for "world". The program should still only print out on one line."
So should we add enough information here to tell our dear reader how to do that? Or should we move that exercise to Python Programming/Input and output, which already has information on 2 different ways to do that? --DavidCary (talk) 04:34, 25 May 2009 (UTC)
- One of our readers (me), found a syntax error and an ^ arrow pointing at the "=" equal sign. I also use python 2.5.2 Vanuan :) . I can then safely ignore it until we get help , or we ourselves help when we learn about it :) Logictheo (talk) 19:39, 25 May 2009 (UTC)
ActivePython 2.6.1.1 (ActiveState Software Inc.) based on
Python 2.6.1 (r261:67515, Dec 5 2008, 13:58:38) [MSC v.1500 32 bit (Intel)] on
win32
Type "help", "copyright", "credits" or "license" for more information.
>>> ("Hello, world!", end="")
File "<stdin>", line 1
("Hello, world!", end="")
^
SyntaxError: invalid syntax
>>>
Must consequently be replaced by a "see also" at the end, toward Python Programming/Input and output. JackPotte (talk) 02:04, 26 May 2009 (UTC)
I find out that on Python 3 teh end statement on the print function actually works. The problem could be that Python 3 the print its a function while on previous version is more of a statement. Dragonecc (discuss • contribs) 18:59, 16 January 2011 (UTC)
Why is my installation not working?
[edit source]When I run the premade "idle.py" with:
Python 2.7.3 (default, Apr 10 2012, 23:24:47) [MSC v.1500 64 bit (AMD64)] on win32
Type "copyright", "credits" or "license()" for more information.
installation, I get:
Traceback (most recent call last):
File "C:\Python27\Lib\idlelib\idle.py", line 7, in <module>
idlelib_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
NameError: name '__file__' is not defined
>>>
Heck, when I even run the simple tutorial "hello2.py" from the instructions on Python Programming/Creating Python programs I get:
>>> ================================ RESTART ================================
>>>
Hello, world!
Hello, world!
>>>
Why is that? I'm trying to get this set up and figured out so I can start using a pywikipediabot variation on this wiki to eliminate the 5,600 spam posts, corresponding images, and ban the posters of said spam.. I have placed all of the pages into a category (Category:Pages flagged for deletion/Spam). I have absolutely no experience with Python, and I am finding it hard to learn with the tutorials not working correctly. *sad face* -- Technical 13 (discuss • contribs) 13:27, 22 April 2012 (UTC)
Use /usr/local/bin instead of /usr/bin
[edit source]/usr/bin is managed by your package manager and you might in trouble. /usr/local can be used for this.