I am wondering if there are any tips or tricks to converting perl into python. It would be nice if there was a script like python's 2to3. Or perhaps some compatibility libraries.
Emacs uses an older version of python(2.3) i have for the default python mode, is there a way for me to tell emacs to use the newer version that i have in my home directory?
btw I'm using a red hat distro and dont have root privileges.
I like the sinatra framework, but might have to work in python. A quick web search has uncovered a few python equivalents including itty, flask and juno.
I'd like to know people's experience of these, or other sinatra equivalents. Which would you recommend?
hi,
I am trying to call webservice from python client using SUDS. When I call a function with a complex data type as input parameter, it is not passed correctly, but complex data type is getting returned correctly froma webservice call.
Webservice Type:
Soap Binding 1.1
Document/Literal
Webserver:
Weblogic 10.3
Python Version: 2.6.5, SUDS version: 0.3.9
here is the code I am using:
Python Client:
from suds.client import Client
url = 'http://192.168.1.3:7001/WebServiceSecurityOWSM-simple_ws-context-root/SimpleServicePort?WSDL'
client = Client(url)
print client
#simple function with no operation on input...
result = client.service.sopHello()
print result
result = client.service.add10(10)
print result
params = client.factory.create('paramBean')
print params
params.intval = 10
params.longval = 20
params.strval = 'string value'
#print "params"
print params
try:
result = client.service.printParamBean(params)
print result
except WebFault, e:
print e
try:
result = client.service.modifyParamBean(params)
print result
except WebFault, e:
print e
print params
webservice java class:
package simple_ws;
import javax.jws.Oneway;
import javax.jws.WebMethod;
import javax.jws.WebService;
import javax.jws.soap.SOAPBinding;
public class SimpleService {
public SimpleService() {
}
public void sopHello(int i) {
System.out.println("sopHello: hello");
}
public int add10(int i) {
System.out.println("add10:");
return 10+i;
}
public void printParamBean(ParamBean pb) {
System.out.println(pb);
}
public ParamBean modifyParamBean(ParamBean pb) {
System.out.println(pb);
pb.setIntval(pb.getIntval()+10);
pb.setStrval(pb.getStrval()+"blah blah");
pb.setLongval(pb.getLongval()+200);
return pb;
}
}
and the bean Class:
package simple_ws;
public class ParamBean {
int intval;
String strval;
long longval;
public void setIntval(int intval) {
this.intval = intval;
}
public int getIntval() {
return intval;
}
public void setStrval(String strval) {
this.strval = strval;
}
public String getStrval() {
return strval;
}
public void setLongval(long longval) {
this.longval = longval;
}
public long getLongval() {
return longval;
}
public String toString() {
String stri = "\nInt val:" +intval;
String strstr = "\nstrval val:" +strval;
String strl = "\nlong val:" +longval;
return stri+strstr+strl;
}
}
so, as issue is like this:
on call: client.service.printParamBean(params) in python client,
output on server side is:
Int val:0
strval val:null
long val:0
but on call: client.service.modifyParamBean(params)
Client output is:
(reply){
intval = 10
longval = 200
strval = "nullblah blah"
}
What am i doing wrong here??
A new web application may require adding Artificial Intelligence (AI) in the future, e.g. using ProLog. I know it can be done from a Java environment, but I am wondering about the opportunities with modern web languages like Ruby or Python. The latter is considered to be "more scientific" (at least used in that environment), but using Google there seems to be a preliminary ProLog implementation for both.
Any suggestions on modern (open source) web languages (like Python or Ruby) in combination with AI?
I've been reading a lot about python-way lately so my question is
How to do dependency injection python-way?
I am talking about usual scenarios when, for example, service A needs access to UserService for authorization checks.
I'm trying to compile Python 2.6 for 64bit, I tried various compile commands but not sure whether those are correct
./configure --with-universal-archs=32-bit --prefix="$HOME/python"
make
make install
What is the correct syntax ... ?
I'm studying Python after a lot of PHP experience and it would be handy to have type-hinting in Python. Looks like eclipse + pydev doesn't support this. Any suggestions?
For example, I want my IDE to show function docstrings and types, when I use it, like:
def f(x: int) -> int:
r"""Adds 3 to x"""
return x + 3
f( #and now IDE shows everything about types
Hi.
I have a text file of URLs, about 14000. Below is a couple of examples:
http://www.domainname.com/pagename?CONTENT_ITEM_ID=100¶m2=123
http://www.domainname.com/images?IMAGE_ID=10
http://www.domainname.com/pagename?CONTENT_ITEM_ID=101¶m2=123
http://www.domainname.com/images?IMAGE_ID=11
http://www.domainname.com/pagename?CONTENT_ITEM_ID=102¶m2=123
I have loaded the text file into a Python list and I am trying to get all the URLs with CONTENT_ITEM_ID separated off into a list of their own. What would be the best way to do this in Python?
Cheers
If Python had a macro facility similar to Lisp/Scheme (something like MetaPython), how would you use it?
If you are a Lisp/Scheme programmer, what sorts of things do you use macros for (other than things that have a clear syntactic parallel in Python such as a while loop)?
How do I create a GUID in Python that is platform independent? I here there is a method using ActivePython on Windows but it's Windows only because it uses COM. Is there a method using plain Python?
Hi
I using buzz-python-client from http://code.google.com/p/buzz-python-client/
In the example:
client.build_oauth_consumer('your-app.appspot.com', 'consumer_secret')
Where can I get a consumer_secret?
Is it possible in Python to run multiple counters in a single for loop as in C/C++? I would want something like -- for i,j in x,range(0,len(x)): I know Python interpretes this differently and why, but I would need to run two loop counters concurrently in a single for...?
Thanks,
Sayan
I am a newcomer to Python and am converting a Perl script. What is the Python equivalent to...
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
Any help is greatly appreciated.
Can someone please give the Java equivalent of the below python (which slices a given array into given parts) which was originally written by ChristopheD here:
def split_list(alist, wanted_parts=1):
length = len(alist)
return [ alist[i*length // wanted_parts: (i+1)*length // wanted_parts]
for i in range(wanted_parts) ]
I don't know any python but can really use the above code in my Java app. Thanks
Is there an application similar to Java's Checkstyle for Python?
By which I mean, I tool that analyzes Python code, and can be run as part of continuous integration (e.g. CruiseControl or Hudson). After analyzing it should produce an online accessible report which outlines any problems found in the code.
Thank you,
So I've got plain python downloaded, so I can run .py files from the command line. Now I want to step it up, have a debugger, be able to call .net or other Windows things, etc...
What's my next step? What's a good Python environment for Windows?
Hi, I'm looking into using Lua in a web project. I can't seem to find any way of directly parsing in pure python and running Lua code in Python.
Does anyone know how to do this?
Joe
I am looking for python stubbing library. Something that could be used to create fake classes/methods in my unit tests.. Is there a simple way to achieve it in python..
Thanks
PS: I am not looking for mocking library where you would record and replay expectation.
Hi,
I wrote a python module. Running python filename.py, only checks for syntax errors. Is there a tool, which checks for runtime errors also, like concatenating int with string etc..
Thank you
Bala
File "/usr/local/lib/python2.5/site-packages/libxml2.py", line 1, in <module>
import libxml2mod
ImportError: /usr/local/lib/python2.5/site-packages/libxml2mod.so:
undefined symbol:xmlTextReaderSetup
>>> import libxml2mod
>>> import libxml2
>>>
on Python Prompt it works fine !!
can anyone has idea why my program is not working from .py file as import is working perfect from python prompt.
For a Bash completion script I need to get all the variables from an installed Python module that match a pattern. I want to use only Python-aware functionality, to avoid having to parse comments and such.