This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2011-09-14 17:22:57

maxskywalker
Scratcher
Registered: 2008-01-27
Posts: 1000+

Various Areas of Python

Okay, so I'm proficient in Python, but not quite perfect (and know nothing about PyGame- gonna get to that after I finish Classes, which should be soon.  Yay!).  As such, there are some things that I don't understand.  I use Python 3, by the way.

1.  Why use objects to indirectly access methods instead of just directly accessing static methods?
Resolved

2.  How is PyGame for 3D?
Resolved.

3.  Can Python work with internet?
Resolved.

4.  How does Python/PyGame make .exe files instead of .py files (imagine something like WoW or CoD where you can just right-click on the program and choose 'edit in IDLE' to hack the entire game).
Resolved.

5.  How do you make a project using multiple programming languages in the same project (I heard about a few things that did like Ruby and Perl or something like that some years back)?
Resolved.

6.  Can I control the color of the text printed without resorting to PyGame?
Resolved.

7.  Is Python capable of handling time (as in 'wait so-and-so seconds')?
Resolved.

8.  Exactly how would you make a 3D world in PyGame?

9.  What's inside the object class (as in 'class ThisClass:' versus 'class ThisClass(object):')?

10.  How do I make a module that can be accessed from anywhere on my computer, like random, sys, etc?

11.  Does Jython allow Java scripts or does it just run on the Java VM?

Wow, longer list than I expected.  5 doesn't really matter.  All the otheres do.  If PyGame doesn't do 3D well, I can use Ogre3D.  And while a cool idea, it's probably a real pain to debug 2 programming languages at once.

Edit: As for those of you who are wondering why some of these are important, keep up with my posts (I don't post threads often, so it should be easy).  It has to do with the following:

the road goes ever on and on
from the door where it began.
now far ahead the road has gone
and i must follow if i can,
pursuing it with weary feet
until it joins some larger way
where many paths and errands meet;
and whither then? i cannot say.
(The Lord of the Rings)

***

alive without breath;
cold as death;
never thirsting, ever drinking;
clad in mail, never clinking.
drowns on dry land;
thinks an island is a mountain;
thinks a fountain is a puff of air
    so sleek! so fair!
we only wish to catch a fish,
so juicy-sweet!
(The Lord of the Rings)

***

Orome by which the teleri resided
was left behind to memory.
So that as the elves built their boats,
the shore was left behind.
(Me)

***

all that is gold does not glitter,
all who wander are not lost.
the old that is strong does not whither;
deep roots are not touched by frost.
from the ashes a fire shall be woken,
a light from the shadows shall spring.
renewed shall be the blade that was broken;
the crownless again shall be king.
(The Lord of the Rings)

***

On short grass my feet continue,
and long will they go on-
beyond the horizon, and back.
So shrugging off their weariness,
my feet lead me on and on.
(Me)

***

three rings for the elven-kings
under the sky;
seven for the dwarf-lords
in their halls of stone;
nine for mortal men,
doomed to die.
one ring for the dark lord, on his dark throne.
in the land of mordor where the shadows lie.
one ring to rule them all, one ring to find them;
one ring to bring them all, and in the darkness bind them

in the land of mordor where the shdows lie.
(The Lord of the Rings)

***


Points for whoever figures that one out.  Look for similarities in the poems.  It works if it's start on log-in.  And yes, ALL of the questions have to do with it.  big_smile   If you can guess, then you know that it is a unique idea.  And yeah, I suck at poery.  The only good ones come from The Lord of the Rings.  And yeah, I make references to the Silmarillion.  Heavy references.  Read them anyway, though, please....  They're important.

Last edited by maxskywalker (2011-10-02 21:01:25)

Offline

 

#2 2011-09-14 17:36:00

nickbrickmaster
Scratcher
Registered: 2010-02-02
Posts: 500+

Re: Various Areas of Python

maxskywalker wrote:

7.  Is Python capable of handling time (as in 'wait so-and-so seconds')?

You can use

Code:

sleep 5000

That's for 5 secs.
I'm just learning python.


Ask me what I'm doing, wait an hour than roll a die, if it's 4-6, I'm playing Skyrim, if it's 1, I'm eating, if it's 2-3 I'm programming.
Steam: nickbrickmaster | RotMG: PwnThemAll | Minecraft: nickbrickmaster | League Of Legends: BaneOfTitans

Offline

 

#3 2011-09-14 17:59:21

maxskywalker
Scratcher
Registered: 2008-01-27
Posts: 1000+

Re: Various Areas of Python

Oh, and grade my poetry?  Every other poem is mine.

Offline

 

#4 2011-09-14 18:28:54

AtomicBawm3
Scratcher
Registered: 2009-06-27
Posts: 1000+

Re: Various Areas of Python

Python can handle time, I believe it uses a "tick" which is .001 seconds.

Python can work the internet, part of YouTube's programming is in Python, so there is someway to get it to work online.

Pygame can handle 3d pretty well as far as I've seen, but it does take a lot of math and such.


http://i50.tinypic.com/j0yw0p.jpg

Offline

 

#5 2011-09-14 18:33:14

maxskywalker
Scratcher
Registered: 2008-01-27
Posts: 1000+

Re: Various Areas of Python

AtomicBawm3 wrote:

Python can handle time, I believe it uses a "tick" which is .001 seconds.

Python can work the internet, part of YouTube's programming is in Python, so there is someway to get it to work online.

Pygame can handle 3d pretty well as far as I've seen, but it does take a lot of math and such.

Thank.  So it's tick(1000) for a 1 sec pause.   That really helps.  Oh, and how's my riddle?

Offline

 

#6 2011-09-14 18:36:58

maxskywalker
Scratcher
Registered: 2008-01-27
Posts: 1000+

Re: Various Areas of Python

AtomicBawm3 wrote:

Python can handle time, I believe it uses a "tick" which is .001 seconds.

Not working...

Offline

 

#7 2011-09-14 19:40:24

AtomicBawm3
Scratcher
Registered: 2009-06-27
Posts: 1000+

Re: Various Areas of Python

maxskywalker wrote:

AtomicBawm3 wrote:

Python can handle time, I believe it uses a "tick" which is .001 seconds.

Not working...

I don't think you use the word tick...I think you have to define a variable in a certain way...hold on, I know the video that explained it...


http://i50.tinypic.com/j0yw0p.jpg

Offline

 

#8 2011-09-14 19:43:24

AtomicBawm3
Scratcher
Registered: 2009-06-27
Posts: 1000+

Re: Various Areas of Python

http://stackoverflow.com/questions/1563 … -in-python
Here's a way to do it.

EDIT: http://stackoverflow.com/questions/1333 … rom-python
and another.

Last edited by AtomicBawm3 (2011-09-14 19:45:09)


http://i50.tinypic.com/j0yw0p.jpg

Offline

 

#9 2011-09-14 19:58:35

AtomicBawm3
Scratcher
Registered: 2009-06-27
Posts: 1000+

Re: Various Areas of Python

Found the video.

Also, this is in the middle of good series to look at for Pygame, but it cuts off randomly like all his python tutrorials, so you're not going to learn too much from it.


http://i50.tinypic.com/j0yw0p.jpg

Offline

 

#10 2011-09-14 20:38:29

maxskywalker
Scratcher
Registered: 2008-01-27
Posts: 1000+

Re: Various Areas of Python

AtomicBawm3 wrote:

Found the video.

Also, this is in the middle of good series to look at for Pygame, but it cuts off randomly like all his python tutrorials, so you're not going to learn too much from it.

Oh.  Got it.  So it's a PyGame thing.  How about the other questions?  Or the riddle?

Offline

 

#11 2011-09-14 21:40:52

AtomicBawm3
Scratcher
Registered: 2009-06-27
Posts: 1000+

Re: Various Areas of Python

6 depends on what you're printing it in...if you're printing it in the python.exe or IDLE, nope, but if you use wxpython or pygame or something else I can't remember the name of, you can.


http://i50.tinypic.com/j0yw0p.jpg

Offline

 

#12 2011-09-14 21:48:07

bananaman114
Scratcher
Registered: 2010-03-15
Posts: 1000+

Re: Various Areas of Python

My guess is that it's a Lotr Rpg seeing as you inquired about time and that you posted that long LOTR thing


the sun still shines

Offline

 

#13 2011-09-14 22:50:47

nickbrickmaster
Scratcher
Registered: 2010-02-02
Posts: 500+

Re: Various Areas of Python

Is there a way you can "go to" a line?


Ask me what I'm doing, wait an hour than roll a die, if it's 4-6, I'm playing Skyrim, if it's 1, I'm eating, if it's 2-3 I'm programming.
Steam: nickbrickmaster | RotMG: PwnThemAll | Minecraft: nickbrickmaster | League Of Legends: BaneOfTitans

Offline

 

#14 2011-09-14 23:05:16

Harakou
Community Moderator
Registered: 2009-10-11
Posts: 1000+

Re: Various Areas of Python

nickbrickmaster wrote:

Is there a way you can "go to" a line?

Short answer: no. There is no "goto" statement as in BASIC and other similar languages.

It's better to just organize your code using subroutines and proper structuring, rather than having goto statements leading all over the place anyway.


http://www.blocks.scratchr.org/API.php?action=random&return=image&link1=http://i.imgur.com/OZn2RD3.png&link2=http://i.imgur.com/duzaGTB.png&link3=http://i.imgur.com/CrDGvvZ.png&link4=http://i.imgur.com/POEpQyZ.png&link5=http://i.imgur.com/ZKJF8ac.png

Offline

 

#15 2011-09-15 08:33:32

maxskywalker
Scratcher
Registered: 2008-01-27
Posts: 1000+

Re: Various Areas of Python

bananaman114 wrote:

My guess is that it's a Lotr Rpg seeing as you inquired about time and that you posted that long LOTR thing

Nope.  I'm just obssessed with LOTR poetry.

Last edited by maxskywalker (2011-09-15 10:33:39)

Offline

 

#16 2011-09-15 10:37:04

maxskywalker
Scratcher
Registered: 2008-01-27
Posts: 1000+

Re: Various Areas of Python

bananaman114 wrote:

My guess is that it's a Lotr Rpg seeing as you inquired about time and that you posted that long LOTR thing

Hint: only mine matter.

Offline

 

#17 2011-09-15 14:10:55

maxskywalker
Scratcher
Registered: 2008-01-27
Posts: 1000+

Re: Various Areas of Python

. . .

Offline

 

#18 2011-09-15 14:12:36

fanofcena
Scratcher
Registered: 2008-07-03
Posts: 1000+

Re: Various Areas of Python

i dunno about python .. seriously lol .. never thought of learning it -_- .. but yeah this forum is making me go give a try and learn my 14th language!! woot woot!


http://i53.tinypic.com/2vxr2c0.png Click whats above u might make a cute planet happy ^_^

Offline

 

#19 2011-09-15 14:14:44

maxskywalker
Scratcher
Registered: 2008-01-27
Posts: 1000+

Re: Various Areas of Python

fanofcena wrote:

i dunno about python .. seriously lol .. never thought of learning it -_- .. but yeah this forum is making me go give a try and learn my 14th language!! woot woot!

O... kay....  It's a bit like what I've seen of BASIC, or Eifell, though I don't use them.

Offline

 

#20 2011-09-15 16:20:49

maxskywalker
Scratcher
Registered: 2008-01-27
Posts: 1000+

Re: Various Areas of Python

maxskywalker wrote:

fanofcena wrote:

i dunno about python .. seriously lol .. never thought of learning it -_- .. but yeah this forum is making me go give a try and learn my 14th language!! woot woot!

O... kay....  It's a bit like what I've seen of BASIC, or Eifell, though I don't use them.

Or maybe Lua?  But with colons.

Offline

 

#21 2011-09-16 08:59:41

maxskywalker
Scratcher
Registered: 2008-01-27
Posts: 1000+

Re: Various Areas of Python

Um, right.  Now, aside from that offtopic bit...
can we get back on subject now?

Offline

 

#22 2011-09-16 12:23:51

maxskywalker
Scratcher
Registered: 2008-01-27
Posts: 1000+

Re: Various Areas of Python

Extra hint added.

Offline

 

#23 2011-09-16 17:24:13

nickbrickmaster
Scratcher
Registered: 2010-02-02
Posts: 500+

Re: Various Areas of Python

Hey max, I was wondering if you knew anything about the "Pickle" way of saving files in python. In my program, it's supposed to save a list, but when it does the pickle.dump(), I get an error saying

Error wrote:

Traceback (most recent call last):
  File "Z:\python_programs\Textgame1", line 124, in <module>
    pickle.dump(savelist, Name + "textventure.txt")
  File "C:\Python26\lib\pickle.py", line 1362, in dump
    Pickler(file, protocol).dump(obj)
  File "C:\Python26\lib\pickle.py", line 203, in __init__
    self.write = file.write
AttributeError: 'str' object has no attribute 'write'

Can you help? Much thanky.


Ask me what I'm doing, wait an hour than roll a die, if it's 4-6, I'm playing Skyrim, if it's 1, I'm eating, if it's 2-3 I'm programming.
Steam: nickbrickmaster | RotMG: PwnThemAll | Minecraft: nickbrickmaster | League Of Legends: BaneOfTitans

Offline

 

#24 2011-09-16 17:42:46

fire219
Scratcher
Registered: 2008-02-07
Posts: 1000+

Re: Various Areas of Python

I am working on making a web browser in Python, and ran a little test with this code:

Code:

import http.client
load = http.client.HTTPConnection('example.com')
load.request("GET", "/")
r1 = load.getresponse()
print(r1.read)
sleep 5000

but it says that "sleep 5000" is invalid syntax. Can anyone help?

(I am using Python 3.2)

EDIT: Nevermind, I found out i need to import the "time" module and use "time.sleep(#).  tongue

Last edited by fire219 (2011-09-16 17:46:42)


http://bluetetrarpg.x10.mx/usercard/img.php?name=fire219

Offline

 

#25 2011-09-16 17:43:45

wulfmaster
Scratcher
Registered: 2011-04-23
Posts: 500+

Re: Various Areas of Python

don't you need to import the time plugin?


Social Connections - Bringing communities close together! http://cyberkidscountry.com/ip.php

Offline

 

Board footer