Hi,
I need to write a program to scrape forums.
Should I write the program in Python using the Scrapy framework or should I use Php cURL?
Also is there a Php equivalent to Scrapy?
Thanks
can i create a case insensitive string column in sqlalchemy? im using sqlite, and theres probaby a way to do it through DB by changing collation, but i want to keep it in sqlalchemy/python.
How can I produce a timestamp to millisecond accuracy from a date or datetime in Python?
There are an overwhelming number of methods and ways of doing this, and I'm wondering which is the most Pythonic way.
What am I doing wrong/what can I do?
import sys
import string
def remove(file):
punctuation = string.punctuation
for ch in file:
if len(ch) > 1:
print('error - ch is larger than 1 --| {0} |--'.format(ch))
if ch in punctuation:
ch = ' '
return ch
else:
return ch
ref = (open("ref.txt","r"))
test_file = (open("test.txt", "r"))
dictionary = ref.read().split()
file = test_file.read().lower()
file = remove(file)
print(file)
This is in Python 3.1.2
I wrote a function in Python:
def instantiate(c):
if inspect.isclass(c): return c()
elif isinstance(c, object): return c
else: raise Exception, '%s is not an object or class.' % c
Now I want to do the opposite: get the class from an already instantiated object so that I can re-instantiate it with different parameters. How can I do that?
Hey,
Imagine I have a video playing.. Can I have some sort of motion graphics being played 'over' that video.. Like say the moving graphics is on an upper layer than the video, which would be the lower layer..
I am comfortable in a C++ and Python, so a solution that uses these two will be highly appreciated..
Thank you in advance,
Rishi..
I'm trying to use cocoa-python with Xcode but it always calls up the error:
Traceback (most recent call last):
File "main.py", line 10, in <module>
import objc
ImportError: No module named objc
This seems to be because dispite all my attempts to install or find objc and the other modules used by that file, they are simply not on my computer that I can tell, so does anyone know where I can download the actual files (or could put up their own copies?) as in objc.py, Foundation.py, AppKit.py and PyObjCTools.py?
I saw this video, and I am really curious how it was performed. Does anyone have any ideas? My intuition is that he scraped pixels from the screen (one per 'box'), and then fed that into some program to determine the next move.
Is scraping pixel-by-pixel the way to do this, or is there a better way? I am looking to do something similar with either Java or Python.
Thanks
Hi,
I need huffman code(best in python or in java), which could encode text not by one character (a = 10, b = 11), but by two (ab = 11, ag = 10). Is it possible and if yes, where could i find it, maybe it's somewhere in the internet and i just can'd find it?
I have a lot of duplicate image files on my Windows computer, in different subfolders and with different filenames.
What Python script or freeware program would you recommend for removing the duplictes?
(I've read this similar question, but the poster there is asking about visual duplicates with differing filesizes. Mine are exact duplicates with different filenames.)
Which of the following technology is easy to learn and fun for developing a website? If you could only pick one which would it be and why
Clojure/Compojure+Ring/Moustache+Ring
Groovy/Grails
Python/Django
Ruby/Rails
Turbogear
Cappuccino or Sproutcore
Javascript/jQuery
I've been teaching myself object oriented programming and I'm thinking about a situation where I have an object "Transaction", that has quite a few properties to it like account, amount, date, currency, type, etc.
I never plan to mutate these data points, and calculation logic will live in other classes. My question is, is it poor Python design to instantiate thousands of objects just to hold data? I find the data far easier to work with embedded in a class rather than trying to cram it into some combination of data structures.
So I'm going through the matplotlib documentation and prepared to use the iPython interactive Python shell with ipython -pylab. However I get this:
Az's MBP:~ Az$ ipython -pylab
-bash: ipython: command not found
Did I fail to install iPython? I used easy_install as advised.
Any ideas?
Hi guys, I have to get linux distro name from python script. There is dist method in platform module:
import platform
platform.dist()
But it returns
>>> platform.dist()
('', '', '')
Under my Arch Linux. Why? How can I get the name.
p.s. I have to check whether the distro is debian-based.
I'm trying to install this:
http://www.coderholic.com/pywebshot-generate-website-thumbnails-using-python/
I've googled a lot,and still can't make it work(gtk runtime has been installed successfully(gtk-demo works),but it still reports can't find MSVCR80.dll,this should be because that I have installed Microsoft Visual Studio 9.0?),
each time it reports ImportError: DLL load failed,MSVCR80.dll is not found..
How to make an application that needs MSVCR80.dll work when I've already installed Microsoft Visual Studio 9.0?
Or :
How to make _gtk.pyd use MSVCR90.dll instead of MSVCR80.dll?
I am planning to use py2exe to make an application developped with Python 2.6.
It seems that my app need the VC redistribuables : http://www.py2exe.org/index.cgi/Tutorial#Step5
I've read this tutorial and the redistribuables license agreement and I am not sure if I can freely redistribute these files with my program. (I don't have VS2008 license)
Can I bundle the redistribs into an installer and make the installation transparent for the user or do they have to download the files by their own from Microsoft website?
Thanks in advance
I swear this should be so easy... Why is it not? :(
In fact, I want to combine 2 parts of the same array to make a complex array:
Data[:,:,:,0] , Data[:,:,:,1]
These don't work:
x = np.complex(Data[:,:,:,0], Data[:,:,:,1])
x = complex(Data[:,:,:,0], Data[:,:,:,1])
Am I missing something? Does numpy not like performing array functions on complex numbers? Here's the error:
TypeError: only length-1 arrays can be converted to Python scalars
Cheers
I want to make my component faster, I am using Javascript and JQuery to build that.
I am using JSON object to communicate with component and back-end is python.
Is there any suggestion to make component faster?
this: http://code.google.com/intl/en/appengine/docs/python/tools/devserver.html
The web server can use an SMTP server, or it can use a local installation of Sendmail.
i download the Sendmail lib,and find it is so big, and so many doc,
i want to know which way is better,
and if the Sendmail way is better, how to use it simplely,
thanks
According to this python page, oursql looks very cool.
oursql has real parameterization.
oursql allows text or binary data to be streamed into the database and streamed out of the database, instead of requiring everything to be buffered in the client.
oursql can both insert rows lazily and fetch rows lazily.
oursql has unicode support on by default.
So, Anyone start using it in the live projects and could share pros and cons over it?
Python and Matlab quite often have integer date representations as follows:
733828.0
733829.0
733832.0
733833.0
733834.0
733835.0
733836.0
733839.0
733840.0
733841.0
these numbers correspond to some dates this year. Do you guys know which function can convert them back to YYYYMMDD format?
thanks a million!
Are there any libraries or frameworks that provide the functionality of a browser, but do not need to actually render physically onto the screen?
I want to automate navigation on web pages (Mechanize does this, for example), but I want the full browser experience, including Javascript. Thus, I'd like to have a virtual browser of some sort, that I can use to "click on links" programmatically, have DOM elements and JS scripts render within it, and manipulate these elements.
Solution preferably in Python, but I can manage others.
I'm about to start an App Engine project for the first time. Most likely with Python. I was wondering if anybody could give me a leg up by detailing their workflow when developing for it. What tools do you use to go from start to deployed? Did you do any app engine specific configurations to those tools?