Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Custom types and Embed Java in Python
Index -> Programming, Python -> Python Help
Goto page 1, 2  Next
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Nathan4102




PostPosted: Fri Apr 05, 2013 8:43 am   Post subject: Custom types and Embed Java in Python

Two quick questions:

First, is it possible to create a variable type in python? I'm looking for a type formatted like (x, y) to store co-ordinates that I could call like:

Python:
Point1 = (2, 4)
MoveMouse(Point1.x, Point1.y)

#OR

MoveMouse(Point1[x], Point1[y])

#Preferably not

MoveMouse(Point1[0], Point1[1])


Is this possible?

Second question, I'm working on a Runescape marco'ing client to work on my python skills, but I'm wondering if its even possible to get a Runescape client inside a python GUI. I don't need to be told exactly how to do it, but if someone could tell me what I'd need to do it, or lead me in the right direction, that would be great!

Thanks,
Nathan
Sponsor
Sponsor
Sponsor
sponsor
wtd




PostPosted: Fri Apr 05, 2013 9:45 am   Post subject: RE:Custom types and Embed Java in Python

Tuples are already a part of Python.

code:
>>> type((2,3))
<type 'tuple'>
>>>
Nathan4102




PostPosted: Fri Apr 05, 2013 12:43 pm   Post subject: RE:Custom types and Embed Java in Python

It'll do, but is there any way to address the first number with X and the second with Y like in my example?
wtd




PostPosted: Fri Apr 05, 2013 12:48 pm   Post subject: RE:Custom types and Embed Java in Python

Perhaps you should use a dictionary.
Nathan4102




PostPosted: Fri Apr 05, 2013 1:38 pm   Post subject: RE:Custom types and Embed Java in Python

Dictionaries are supposed to be used like constants, non changing, correct? I'd have my points changing constantly. Is there really no way to create a new variable type?
wtd




PostPosted: Fri Apr 05, 2013 2:48 pm   Post subject: RE:Custom types and Embed Java in Python

code:
>>> foo = { "x": 42, "y": 27 }
>>> foo["x"]
42
>>> foo["x"] = 3
>>> foo["x"]
3
>>>
Nathan4102




PostPosted: Fri Apr 05, 2013 3:02 pm   Post subject: RE:Custom types and Embed Java in Python

Alright, ill make that work. Thanks!
Nathan4102




PostPosted: Fri Apr 05, 2013 3:22 pm   Post subject: RE:Custom types and Embed Java in Python

Still looking for answers to my second question!
Sponsor
Sponsor
Sponsor
sponsor
wtd




PostPosted: Fri Apr 05, 2013 3:59 pm   Post subject: RE:Custom types and Embed Java in Python

Of course, you could always just make a TwoDimensionalPoint class...
Nathan4102




PostPosted: Fri Apr 05, 2013 4:12 pm   Post subject: RE:Custom types and Embed Java in Python

OOP and classes are new to me, could you explain? Smile
Cancer Sol




PostPosted: Fri Apr 05, 2013 5:53 pm   Post subject: Re: Custom types and Embed Java in Python

Even though I'm not sure if it's the right place to ask, but can someone please lead me in the right direction, for Nathan's second question, except, in C++.
It'd be great if someone could just do in Python, idc really, just so that I know what to do Razz
Nathan4102




PostPosted: Fri Apr 05, 2013 6:34 pm   Post subject: RE:Custom types and Embed Java in Python

A browser might work too, as long as it could run a java applet...
linuxp




PostPosted: Sat Apr 06, 2013 1:24 am   Post subject: Re: Custom types and Embed Java in Python

class?

code:

class pos:
    def __init__(self,x,y):
        self.x = x
        self.y = y

pa = pos(10,20)
 
move(pa.x,pa.y)
Tony




PostPosted: Sat Apr 06, 2013 1:37 am   Post subject: RE:Custom types and Embed Java in Python

@Nathan ? it might help if you explain what you want to do with the Java.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Nathan4102




PostPosted: Sat Apr 06, 2013 8:25 am   Post subject: RE:Custom types and Embed Java in Python

Thanks Linux! And tony, I want only the java applet of runescape in my marcoing client from this site: Runescape.com/game.ws

I've seen other clients do it, so it can't be impossible...
Display posts from previous:   
   Index -> Programming, Python -> Python Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 2  [ 29 Posts ]
Goto page 1, 2  Next
Jump to:   


Style:  
Search: