Welcome, Guest. Please login or register.

Author Topic: [Python] Help?  (Read 1192 times)

Offline Alex(aMacUser)

  • Global Moderator
  • General
  • *****
  • Posts: 1194
  • aMacUser is a name I picked up in High School
    • View Profile
    • eG
[Python] Help?
« on: February 14, 2012, 12:30:39 am »
Code: [Select]
import time
pass = str("password123")
password = str(raw_input("Password: "))
time.sleep(4)
if password == pass: #hi
print ('good job')
import os # obvious implements the os module
os.chdir("C:\Program Files (x86)\VideoLAN\VLC")   #path
os.startfile("vlc.exe")    #program
else:
print ("try again")
password = raw_input('password: ')

Ok well It doesnt work. I need help with why it doesn't work.
using python and notepadd++ thanks in advance

I have a lot of Macs probably 10 <> I do not use them to Game
I use a PC which I have Built myself (check the PC specs topic)

Offline Alex(aMacUser)

  • Global Moderator
  • General
  • *****
  • Posts: 1194
  • aMacUser is a name I picked up in High School
    • View Profile
    • eG
Re: [Python] Help?
« Reply #1 on: February 14, 2012, 12:36:08 am »
Code: [Select]
import time
print "this is cool"
time.sleep(3)
message = str("this program works")
print message
time.sleep(3)
yourName = str(raw_input("What is your name my [eG] mate!: "))
print yourName + "!"
time.sleep(4)
print "This is Heaps good" + " " + yourName
time.sleep(2)
print "bye"
time.sleep(1)
#import os uncomment this to access the os module
#os.chdir('C:\Program Files (x86)\VideoLAN\VLC') <--- Un-comment this to launch vlc
#os.startfile("vlc.exe") <--Uncomment this to open launch vlc

This program works. I am sort of confused at why the other one doesn't. Un-comment the stuff that says un-comment to get it to open vlc, assuming you have vlc and it is installed in that directory.

just open notepad++ and paste this in. save it as whatever you want with the file extension of ".py" for python. then run this by double clicking it. it will run as long as you have python installed. if not go to www.python.org and install the python 2.x for either 32 or 64 bit os.

I have a lot of Macs probably 10 <> I do not use them to Game
I use a PC which I have Built myself (check the PC specs topic)

Offline Tom

  • Administrator
  • General
  • *****
  • Posts: 4613
  • Clan Founder
    • View Profile
    • Echo-Gaming.co
[Python] Help?
« Reply #2 on: February 14, 2012, 02:59:45 pm »
What does the program do?


Quote from: John F. Kennedy
Mankind must put an end to war or war will put an end to mankind.

Offline Nemesis

  • [eG] Clan Member
  • Colonel
  • ***
  • Posts: 262
    • View Profile
[Python] Help?
« Reply #3 on: February 14, 2012, 03:41:40 pm »
Auto-Botnet creation that creates ghost-IP's to your game IP what causes it to crash and possibly lets the main server crash.

Nolol just telling BS.
Pretty funny: I was about to study python upcoming week ( just decided to do it, no real study or something else ), so we can teach/help eachother and learn together =]

Offline Alex(aMacUser)

  • Global Moderator
  • General
  • *****
  • Posts: 1194
  • aMacUser is a name I picked up in High School
    • View Profile
    • eG
Re: [Python] Help?
« Reply #4 on: February 21, 2012, 10:53:47 pm »
Yes
Yea we can teach each other!

I have a lot of Macs probably 10 <> I do not use them to Game
I use a PC which I have Built myself (check the PC specs topic)

Offline tronds

  • [eG] Clan Member
  • Captain
  • ***
  • Posts: 72
    • View Profile
    • Trond's Coffee Time
Re: [Python] Help?
« Reply #5 on: July 21, 2012, 03:14:13 pm »
Don't use pass. It's a statement.

However, the pass statement does nothing. It can be used when a statement is required syntactically but the program requires no action. For example:
Code: [Select]
>>>
>>> while True:
...     pass  # Busy-wait for keyboard interrupt (Ctrl+C)
...
This is commonly used for creating minimal classes:

Code: [Select]
>>>
>>> class MyEmptyClass:
...     pass
...
Another place pass can be used is as a place-holder for a function or conditional body when you are working on new code, allowing you to keep thinking at a more abstract level. The pass is silently ignored:

Code: [Select]
>>>
>>> def initlog(*args):
...     pass   # Remember to implement this!
...

Retrieved some of the information from the Python documentation.

Sorry for posting in a zombie thread. I hope it's OK as the problem was unsolved.
« Last Edit: July 21, 2012, 03:17:26 pm by tronds »

Offline Tom

  • Administrator
  • General
  • *****
  • Posts: 4613
  • Clan Founder
    • View Profile
    • Echo-Gaming.co
Re: [Python] Help?
« Reply #6 on: July 21, 2012, 04:39:07 pm »
I tried to code a server status script in Python, and it's seriously difficult. It's such a high-level language compared to anything that I usually use. Indenting instead of brackets is a little confusing from the start, and no multi-line comments is a bummer. :P


Quote from: John F. Kennedy
Mankind must put an end to war or war will put an end to mankind.

Offline tronds

  • [eG] Clan Member
  • Captain
  • ***
  • Posts: 72
    • View Profile
    • Trond's Coffee Time
Re: [Python] Help?
« Reply #7 on: July 22, 2012, 05:50:33 am »
You can actually use multi line comments in Python.

Just use use triple-quoted strings. When they're not a docstring (first thing in a class/function/module), they are ignored.

Code: [Select]
'''
This is a multiline
comment.
'''

Source: Stack Overflow