Quantcast

Jump to content


Photo

Creating A Basic Refresher


  • Please log in to reply
26 replies to this topic

#1 414de7fe6

414de7fe6
  • 2559 posts

Posted 31 December 2004 - 09:45 PM

Right, most of you are wanting to learn how to program, but dont know where to start and cant afford any of the higher class programs such as visual basic 6 enterprise, or devsharp c++ enterprise.

Python is just as powerful as vb6 or c++, and is free and extremely easy to learn. However, creating gui apps in vb6 is MUCH easier than it is in python, but python is a multi-platform support language, which means it can be used on mac, linux even unix as well as windows.

To start, you'll need to download ActiveState ActivePython 2.4 which is a gui python ide compiler, allowing you to run your scripts as you make them. You'll also need python itself, as the ide doesnt come with the interperater itself.

Install python then activepython, and run activepython.

You'll see a interactive window, Do not close this. As it is your ide based command line, everything your script will do will output into this window.

Click the page button up under the file menu. Choose python script and you'll see another blank window. This is your empty script.

First of all, your going to need to learn how to comment things. Python doesnt have end subs or void.close like vb6, java and the c series have, its all based on indentation. To indent something, you si'mply press the tab key, and press backspace to end it.

To comment something, you go: #Commentbase here or """ comment here """.

Comment the first two lines of your script as Basic Refesher and a line of equals =.

You aint going to know any of the syntax. So thats why I'm here.

The program we will be making today is stated below, both in source and in explanation, You wont understand any of what it does unless you read both the source and the explanation.

#Basic Refresher Script - By Your Name Here
#==========================================
I'mport urllib #urlib is the python equivilant to webbrowser/inet/winsock or c series IO stream

def PageGet(url): #this is defining a function, this function must be declared at the top or bottom, CODE GOES INBETWEEN
    pData = urllib.urlopen(url).read()
    return pData
#you noticed how this isnt indented? this is how python works. indenting a function
#or if command starts it and ends it.
yData = raw_input("What is the URL you wish to refresh?") #this is a raw input, which creates a window asking for input.
y2Data = input("How many ti'mes do you wish to refresh the page? numerical values only")
#See anything different? Raw input allows ascii, but input only allows numerical values.
Ti'mesRefreshed = 0
#we are now going to begin the refreshing progress.
Ti'mesRefeshed = Ti'mesRefreshed + 1
PageGet(yData) #capitalasion is I'mportant.
print "Refeshed",Ti'mesRefreshed,"ti'me/s"

The comments mostly explain it.

pData = urllib.urlopen(url).read() = this will ask for a url and read it, this can be used to grab the source of a page easily.

y2Data = input("How many ti'mes do you wish to refresh the page? numerical values only") = this is a input. numerical values only will be added to the string. raw_input is for ascii.

If you wish to learn more about this, and how to make GUI apps in python, google the web for python gui tutorials or python tkinter tutorials.

~Ariadene

This tutorial is only to be used on www.neocodex.us, and www.darkerbyte.tk.

#2 redlion

redlion
  • I don't exist!

  • 12072 posts


Users Awards

Posted 13 January 2005 - 03:52 PM

I encountered a problem with the link for the Activestate compiler. I use windows XP, I don't know if that will change anything. The actual program is still there, the command script that is. Very nice guide, especially for those nubs like me with no knowledge of these things at all.

Edited by redlion, 13 January 2005 - 03:55 PM.


#3 Dominate

Dominate
  • 2090 posts

Posted 13 January 2005 - 04:50 PM

I dont get this but hummm just ai'm me for visual basic 6 for a cheap price :(

#4 dagger

dagger
  • 1 posts

Posted 16 January 2005 - 04:26 PM

Euphoria, you are a fool to say that Python is better than C++. learn the CENSOREDing facts you retard.

#5 Faisal

Faisal
  • 1989 posts

Posted 16 January 2005 - 06:13 PM

Euphoria, you are a fool to say that Python is better than C++. learn the CENSOREDing facts you retard.

View Post


What a really rude person... ^_^

#6 414de7fe6

414de7fe6
  • 2559 posts

Posted 16 January 2005 - 07:30 PM

Euphoria, you are a fool to say that Python is better than C++. learn the CENSOREDing facts you retard.

View Post

Right, you've got me pissed you idiot.

Take the facts yourself PYTHON IS BETTER TO LEARN THAN C++ AS PYTHON CAN BE USED WEB-BASED WHILE C++ IS Li'mITED TO STAND ALONE!!

As for you, the ignorant female dog, go learn c++ and python then come back and tell me which one is easier to learn. 3 lines in python to open a connect, 40-90 codes of API scripting to get it to open a webpage. Another 100 to make it grab the source.

And I bet you dont even program, you anti-social sod.

As for the others,

Redlion, Python is not GUI based, it is a command line script, much like java/c# but has a GUI library called tkinter. You can manipulate this library. Google EasyGUI and follow the instructions, you can easily make nice full scale programs with that.

To make exe's using python, Google py2exe and follow the instructions.

To make python work on the web, you need to have a host that supports mod_python and python2.4. Then you'll need to learn python server pages, which isnt as hard.

For instance:

[code=auto:0]
<html>
<%
name = form.key.getkey()
%>
Hi, <% name %>! Welcome to python server pages!
</html>

Running that script on a server with mod_python would result in this..

Go: name.psp?name=john
Hi, john! Welcome to python server pages!

I'm working on a carapace (shell interpereter) for python web now, meaning you can do this with ease:

PageCreate.carapace(element1,element2,indexpage,basei'mg)

It'd create a whole new directory, force the browser to view the I'mages, which would be all based on pythons drawing library.

Another thing:

phpIntergrate("<?php
                  print "hai!";
                ?>)
Would actually load the PHP system inside the carapace, displaying it on the page..It can be used with PageCreate too.

//Carapace System
I'mport carapace.*

carapace.set(element = phpIntergrate & PageCreate & CloseBuffer)

carapace.init(php.irm) //starts the php server if not alredy started
carapace.init(self) //starts the shell interperter

element1 = "hi!"
element2 = "this is a carapace test page"
indexpage = index.php(phpIntergrate)
basei'mg = carapace.draw(square 1,30 > text 1, 25 = "carapace")

PageCreate(element1,element2,indexpage,basei'mg) with php.irm // spawns the page in the carapace

carapace.exert(PageCreate 1 > phpIntergrate)

//end

Would create a page with this text:

hi! - element1
this is a carapace test page - element2
link - back to index.php
squre thingy - basei'mg

Powered by Carapace 0.1 - spawned at <% date.ti'me.collect %>

Heheh, I find that really cool to use, but thats the only two functions in carapace atm ^^

Neo Wizkid: o.o I don't make such terrible grammar errors. Don't edit my edits Euph ^_^

Edited by Neo Wizkid, 31 January 2005 - 12:37 PM.


#7 Raui

Raui
  • 5687 posts


Users Awards

Posted 16 January 2005 - 08:19 PM

OMFG get off this board you loser don't offend euphoria around me :spank: ^_^

#8 redlion

redlion
  • I don't exist!

  • 12072 posts


Users Awards

Posted 16 January 2005 - 08:26 PM

Erm, dagger... thats not a good way to start your ti'me at codex.

#9 414de7fe6

414de7fe6
  • 2559 posts

Posted 17 January 2005 - 06:53 PM

Heh, the tard is banned now so serves hi'm right.

#10 redlion

redlion
  • I don't exist!

  • 12072 posts


Users Awards

Posted 17 January 2005 - 07:06 PM

Did you see the conversation he had with the admin? it was hillarious how stupid he seemed.

Edit: [mergeti'me]1106017440[/mergeti'me]
Oh, and what I meant by my earlier post was that the link to python worked, but the link to the compiler didn't.

Edit: [mergeti'me]1106017574[/mergeti'me]
Scratch that, what I really meant was that the compiler was malfunctioning. I can't open or install or whatever the dl is supposed to do. It just plain doesn't work.

#11 Stephen

Stephen
  • 3527 posts


Users Awards

Posted 18 January 2005 - 07:39 PM

ROFL. Dagger. You just got you ass owned, too bad you can't see it.

#12 414de7fe6

414de7fe6
  • 2559 posts

Posted 19 January 2005 - 03:20 AM

Install python first redlion, then activepython or else the two conflict and screw each other up.

#13

Posted 19 January 2005 - 07:25 AM

not like I will ever use python :D ill just stick with inet or webrowser :p

#14 414de7fe6

414de7fe6
  • 2559 posts

Posted 23 January 2005 - 10:52 PM

Then you'll be in a shock when vb6 runti'me is removed from the internet when longhorn is released now wont you?

#15 Stephen

Stephen
  • 3527 posts


Users Awards

Posted 24 January 2005 - 12:30 AM

longhorn is CRAP. noway I'm using it.

#16 414de7fe6

414de7fe6
  • 2559 posts

Posted 24 January 2005 - 02:28 AM

The beta is CRAP. The whole windows system is CRAP. I only use it because there isnt a linux/mac version of freelancer.

#17 Stephen

Stephen
  • 3527 posts


Users Awards

Posted 24 January 2005 - 04:43 PM

Windows is good, good enough for us atleast. We dont do that bs you do euph.

#18 414de7fe6

414de7fe6
  • 2559 posts

Posted 25 January 2005 - 03:10 AM

Yeah, I now see why dallas hates you =/

#19 shabba

shabba

Posted 28 January 2005 - 05:18 PM

thats wrong vb6 runti'mes isnt being cut out I longhorn it is being combined into a new type of runti'me file which is updated like windows updates it includes the .NET framework as well. Longhorn isnt due to be released until 2006 which means it will be out in 2007 :rolleyes:

#20 Ender

Ender
  • 4321 posts

Posted 31 January 2005 - 12:35 PM

Yeah, I now see why dallas hates you =/

View Post

o.o I don't hate hi'm... though I admit that asking how to do my BGs over and over again can get annoying.

#21 padora

padora
  • 991 posts

Posted 21 October 2006 - 10:04 PM

I am getting an invalid script error...

My code

Import urllib
def PageGet(url):
pData = urllib.urlopen(url).read()
return pData

yData = raw_input("What is the URL you wish to refresh?")
y2Data = input("How many times do you wish to refresh the page? numerical values only")

TimesRefreshed = 0

TimesRefeshed = TimesRefreshed + 1
PageGet(yData)
print "Refeshed",TimesRefreshed,"times"

The program script is saved in a new folder on my desktop.

On the bottom right it says "Failed to run script - syntax error - invalid syntex"

Edited by padora, 21 October 2006 - 10:05 PM.


#22 soccerkid_2010

soccerkid_2010
  • 26 posts

Posted 21 October 2006 - 10:11 PM

wow. *ish confused*

#23 Shin

Shin
  • 1586 posts

Posted 22 October 2006 - 06:22 AM

QUOTE(padora @ Oct 22 2006, 02:04 AM) View Post

I am getting an invalid script error...

My code

Import urllib
def PageGet(url):
pData = urllib.urlopen(url).read()
return pData

yData = raw_input("What is the URL you wish to refresh?")
y2Data = input("How many times do you wish to refresh the page? numerical values only")

TimesRefreshed = 0

TimesRefeshed = TimesRefreshed + 1
PageGet(yData)
print "Refeshed",TimesRefreshed,"times"

The program script is saved in a new folder on my desktop.

On the bottom right it says "Failed to run script - syntax error - invalid syntex"


i in import needs to be lower-case. It should work now. smile.gif

Edited by shin, 22 October 2006 - 06:23 AM.


#24 Mr. Hobo

Mr. Hobo
  • 8152 posts


Users Awards

Posted 22 October 2006 - 07:14 AM

This is from 2005 o.0

#25 nox

nox
  • 6707 posts


Users Awards

Posted 22 October 2006 - 07:58 AM

it's still a valid tutorial though, isn't it? thanks padora for bumping this, i plan to start learning python today.


0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users