Blockland Forums > Modification Help

Is there a way to call a Torque function using Python and vice versa?

Pages: << < (3/4) > >>

Lugnut:


--- Quote from: Port on June 12, 2012, 04:11:32 AM ---Which exact questions?

--- End quote ---
yours
--- Quote from: Ephialtes on June 12, 2012, 04:13:48 AM ---Django obviously because everyone who writes Python uses it basically - it's just how it's done these days. I'm sure if you learned a bit more about python you'd probably realise this.

BitBucket to keep the code in because lets face it, where else do you keep python code? Also open source is the future!

--- End quote ---
..... this almost seems like trolling..?

not sure how a web development framework is going to help op, but if you say so i guess

Port:


--- Quote from: Ephialtes on June 12, 2012, 04:13:48 AM ---Django obviously because everyone who writes Python uses it basically - it's just how it's done these days. I'm sure if you learned a bit more about python you'd probably realise this.

--- End quote ---

Except OP most likely isn't looking for a web-based solution. Twisted?


--- Quote from: Ephialtes on June 12, 2012, 04:13:48 AM ---BitBucket to keep the code in because lets face it, where else do you keep python code?

--- End quote ---

Developing in a repository system isn't necessary.

Ephialtes:

Adam you should probably wait for DontCare4Free to get here, these jokers clearly don't know anything about Python.

DontCare4Free:


--- Quote from: Ephialtes on June 12, 2012, 06:58:47 AM ---Adam you should probably wait for DontCare4Free to get here, these jokers clearly don't know anything about Python.

--- End quote ---
Hi.


--- Quote from: Port on June 12, 2012, 04:02:34 AM ---Why the hell are you creating functions which have natural language constructs already anyway?

--- End quote ---
Probably as a quick dictionary ("this" is how you do "that" the Python way).


--- Quote from: Ephialtes on June 12, 2012, 04:13:48 AM ---Django obviously because everyone who writes Python uses it basically - it's just how it's done these days. I'm sure if you learned a bit more about python you'd probably realise this.

--- End quote ---
Django is a fairly popular web development framework for Python. Python isn't a single-framework language like Ruby (while Ruby can be used on it's own or with another framework, let's be honest here, when was the last time you saw anyone do it?). Django in itself contributes nothing to general-purpose development and only helps with website-specific tasks.


--- Quote from: Ephialtes on June 12, 2012, 04:13:48 AM ---BitBucket to keep the code in because lets face it, where else do you keep python code? Also open source is the future!

--- End quote ---
Bitbucket is not bound to OSS/"publicness" and is also fully optional. There are several alternatives to choose from, including self-hosting and nothing such at all.


--- Quote from: adam savage on June 11, 2012, 07:57:14 AM ---Python as far as I know doesn't have functions such as GetWord() or GetSubStr(), so I was wondering if I could call torque functions in IDLE,

--- End quote ---
It's a bad idea. Instead, while learning, you might want to look it up in Brian's answer (although I've changed a few things to fix syntax errors, etc).

--- Quote from: Brian Smithers on June 11, 2012, 04:32:27 PM ---
--- Code: ---########################
#Sticks and Stones Lang
#By Brian Smith
#Version 1 Build 1
########################
########################
#SubStr
########################
def getSubStr(string,start,end):
return string[start:end]
def strLen(string):
return len(string)
########################
#Basic Word Functions
########################
def firstWord(string):
return string.split(" ")[0]
def restWords(string):
return string.split(" ")[1:]
def lastWord(string):
return string.split(" ")[-1]
def getWordCount(string):
return len(string.split(" "))
def getWord(string, num):
words = string.split(" ")
if num > len(words):
return None
else:
return words[num]

########################
#Basic Field Functions
########################
def getFieldCount(string):
fields = string.split('\t')
return fields.len()
def getField(string,num):
fields = string.split('\t')
if num > fields.len():
return None
else:
return fields[num]

########################
#Basic Line Functions
########################
def getLineCount(string):
lines = string.split('\n')
return lines.len()
def getLine(string,num):
lines = string.split('\n')
if num > lines.len():
return None
else:
return lines[num]


--- End code ---
[/tt]
:)

--- End quote ---


--- Quote from: adam savage on June 11, 2012, 07:57:14 AM ---and Python functions in Blockland somehow.

--- End quote ---
The simplest way to do with would probably be with the (bundled) SocketServer microframework (more specifically, look into TCPServer and StreamRequestHandler) on the Python side while using regular TCPObjects on the Torque side. One issue, however, is that network IO is asynchroneous/non-blocking in Torque (meaning that the function returns before you have a response) which you'll have to adapt your code for.


Anything else?

Rub:

Lol you all got baited so badly in this topic.

Pages: << < (3/4) > >>

Go to full version