Hi folks,
I need to access a few HTML pages through a Python script, problem is that I need COOKIE functionality, therefore a simple urllib HTTP request won't work.
Any ideas?
Do you know of any existing implementation in any language (preferably python) of any entity set expansion algorithms, such that the one from Google sets ? ( http://labs.google.com/sets )
I couldn't find any library implementing such algorithms and I'd like to play with some of those to see how they would perform on some specific task I would like to implement.
Any help is welcome !
Thanks a lot for your help,
Regards,
Nicolas.
hello all, my question is the following, which is the best way of working XML (kml) with python?, especially script serializable.
thanks for your attention and answers
from tweepy import Stream
from tweepy import OAuthHandler
from tweepy.streaming import StreamListener
ckey='W1VPPrau42ENAWP1EnDGpQ'
csecret='qxtY2rYNN0QT0Ndl1L4PJhHcHuWRJWlEuVnHFDRSE'
atoken='1577208120-B8vGWIquxbmscb9xdu5AUzENv09kGAJUCddJXAO'
asecret='tc9Or4XoOugeLPhwmCLwR4XK8oUXQHqnl10VnQpTBzdNR'
class listener(StreamListener):
def on_data(self,data):
print data
return True
def on_error(self,status):
print status
auth=OAuthHandler(ckey,csecret)
auth.set_access_token(atoken,asecret)
twitterStream=Stream(auth,listener())
twitterStream.filter(track=["car"])
I typed this in my Python shell i got an error...the error was IndentationError: unindent does not match any outer indentation level..Please help me!!!!!!!!!!!
Hello guys, I've an application where, for testing, I need to replace the time.time() call with a specific timestamp, I've done that in the past using ruby
(code available here: http://github.com/zemariamm/Back-to-Future/blob/master/back_to_future.rb )
However I do not know how to do this using Python.
Any hints ?
Cheers,
Ze Maria
There is a recurrence equation on page 1789 of this paper and I need some help making a python program to calculate pi_i. I have no idea what is going on here.
Other references:original paper, pages (according to adobe, not the physical pages) 43 and 86
Hi,
I'm using the following to execute a process and hide its output from Python. It's in a loop though, and I need a way to block until the sub process has terminated before moving to the next iteration.
subprocess.Popen(["scanx", "--udp", host], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
Thanks for any help.
I want to access web service in Python or/and Perl scripts. What are the most popular and reliable libraries today?
I read this question, and I know about SOAPpy and ZSI. Can anybody say something about this libraries? Are they reliable enough for use in production?
i need a simple implementation of ftp that i can setup quickly for some experiments.
is there an equivalent of python -m SimpleHTTPServer for ftp.
Google sarch didn't help.
i just need a simple implentation of ftp that is easy to setup. (so i don't have to go through the installation trouble for a lot of PC's).
Hi all,
I have learnt Python for about a month as a one year's PHPer.And I started from Twisted as I'm working in a corporation supplying webservice.I have finished some simple application such as data transferring service,page images-fetch service etc.But the problem is ,I don't understand the struture of codes I wrote in the programs quite well .Every time I have to write codes by watching an example.And my question is ,should I just try to remember the example code's strutures?Or try to understand them?Suggestions would be very appreciated.
Regards
Hi,
I am trying to call gawk from python in this manner.
import os
import string
import codecs
ligand_file=open( "2WTKA_ab.txt", "r" ) #Open the receptor.txt file
ligand_lines=ligand_file.readlines() # Read all the lines into the array
ligand_lines=map( string.strip, ligand_lines )
ligand_file.close()
for i in ligand_lines:
os.system ( " gawk %s %s"%( "'{if ($2==""i"") print $0}'", 'unique_count_a_from_ac.txt' ) )
My problem is that "i" is not being replaced by the value it represent. The value "i" represents is an integer and not a string. Can anyone help me out?
Cheers,
Chavanak
I am trying to call Python's time.strftime() function using a Unicode format string:
u'%d\u200f/%m\u200f/%Y %H:%M:%S'
(\u200f is the "Right-To-Left Mark" (RLM).)
However, I am getting an exception that the RLM character cannot be encoded into ascii:
UnicodeEncodeError: 'ascii' codec can't encode character u'\u200f' in position 2: ordinal not in range(128)
I have tried searching for an alternative but could not find a reasonable one. Is there an alternative to this function, or a way to make it work with Unicode characters?
is there any option free and opensource to run python from usb stick on windows system (i,e pyhon installed on usb stick ) and can run on every windows sytsem just by pluging the usb stick ?
I was asked to write a code translator that would take a Python program and produce a C program. Do you have any ideas how could I approach this problem or is it even possible?
Thanks, Boda Cydo.
I have a string like this "1 1 3 2 1 1 1 2 1 1 1 1 1 1 1 1,5 0,33 0,66 1 0,33 0,66 1 1 2 1 1 2 1 1 2 0,5 0,66 2 1 2 1 1 1 0 1".
How to add elements to each other in python ?
I've tried :
list = []
for x in str.replace(' ', ''):
list.append(x)
sum = 0
for y in list:
sum = sum + double(x)
but I'm getting errors constantly.
I recently downloaded and installed feedparser with python,
I tried to run it but Netbeans shouts on import:
ImportError: No module named feedparser
restarted the Netbeans, still no go.
I write this python code:
import socks
import socket
socks.setdefaultproxy(socks.PROXY_TYPE_SOCKS5, "64.83.219.7", 58279)
socket.socket = socks.socksocket
socket.setdefaulttimeout(19)
import urllib2
print urllib2.urlopen('http://www.google.com').read()
but when I execute it, I get this error:
urllib2.URLError: <urlopen error timed out>
What am I doing wrong?
I am making a python program which is using classes, I want one class to only selectively inherit from another e.g:
class X(object):
def __init__(self):
self.hello = 'hello'
class Y(object):
def __init__(self):
self.moo = 'moo'
class Z():
def __init__(self, mode):
if mode == 'Y':
# Class will now Inherit from Y
elif mode == 'X':
# Class will now Inherit for X
How can I do this without making another class?
hi,
when I use MySQLdb get this message:
/var/lib/python-support/python2.6/MySQLdb/init.py:34: DeprecationWarning: the sets module is deprecated from sets import ImmutableSet
I try filter the warning with
import warnings
warnings.filterwarnings("ignore", message="the sets module is deprecated from sets import ImmutableSet")
but, I not get changes.
any suggestion?
Many thanks.
I want to reproduce the behavior of the command CHOICE in DOS batch but with python.
raw_input requires the user to type whatever then press the ENTER/RETURN key. What I really want is for the user to press a single key and the script to continue from there.
I am trying to export a list of text strings from Python to MATLAB using scipy.io. I would like to use scipy.io because my desired .mat file should include both numerical matrices (which I learned to do here) and text cell arrays.
I tried:
import scipy.io
my_list = ['abc', 'def', 'ghi']
scipy.io.savemat('test.mat', mdict={'my_list': my_list)
In MATLAB, I load test.mat and get a character array:
my_list =
adg
beh
cfi
How do I make scipy.io export a list into a MATLAB cell array?
I have this list:
names = ['john','Jonh','james','James','Jardel']
I want loop over the list and handle consecutive names with a case insensitive match in the same iteration. So in the first iteration I would do something with'john' and 'John' and I want the next iteration to start at 'james'.
I can't think of a way to do this using Python's for loop, any suggestions?
I'm making a small script in python with ttk and I have a problem where a function runs where it shouldn't. The button code looks as follows:
btReload = ttk.Button(treeBottomUI, text="Reload", width=17, command=loadModelTree(treeModel))
btReload.pack(side="left")
and the function is as this:
def loadModelTree(tree):
print ("Loading models...")
allModels = os.listdir(confModPath)
for chunk in allModels:
...
For some reason, the function runs without the button being pressed. Why?
Hi,
Trying to load a shared lib out of the current '.' dir in a unit test on osx.
What works on Linux and Netbsd there is a symlink _mymodule.so --> ../.libs/libmymodule.so
but on osx, python's import mymodule won't find
_mymodule.dylib --> ../.libs/libmymodule.dylib
I've tried adding
export DYLD_LIBRARY_PATH=.:$DYLD_LIBRARY_PATH
to the script env, nogo. Any help appreciated.
-Ed
What is an efficient way to find the most common element in a Python list?
My list items may not be hashable so can't use a dictionary.
Also in case of draws the item with the lowest index should be returned. Example:
>>> most_common(['duck', 'duck', 'goose'])
'duck'
>>> most_common(['goose', 'duck', 'duck', 'goose'])
'goose'