Looking to use FastLZ in Python, or something similar. Tried Google and didn't find anything. Wondering if there is another algorithm with similar performance available in Python?
When considering social web app architecture, is it a better approach to document user social patterns in a database or in logs? I thought for sure that behavior, actions, events would be strictly database stored but I noticed that some of the larger social sites out there also track a lot by logging what happens.
Is it good practice to store prominent data about users in a database and since thousands of user actions can be spawned easily, should they be simply logged?
What is the purpose of the 'self' word in python. I understand it refers to the specific object created from that class, but i cant see why it explicitly needs to be added to very function as a parameter. To illustrate, in ruby, i could do this:
class myClass
def myFunc(name)
@name = name
end
end
Which i understand, quite easily, However in python i need to include self:
class myClass:
def myFunc(self, name):
self.name = name
Can anyone talk me through this?
Any help would be appreciated.
I am attempting to to use python to gain some performance on a task that can be highly parallelized using http://docs.python.org/library/multiprocessing.
When looking at their library they say to use chunk size for very long iterables. Now, my iterable is not long, one of the dicts that it contains is huge: ~100000 entries, with tuples as keys and numpy arrays for values.
How would I set the chunksize to handle this and how can I transfer this data quickly?
Thank you.
I am using a shared hosting environment that will not give me access to the command line.
Can I download the python module on my computer, compile it using python setup.py installand then simply upload a .py file to the web host?
If yes, where does the install statement place the compiled file?
Is there a way to encrypt files (.zip, .doc, .exe, ... any type of file) with Python?
I've looked at a bunch of crypto libraries for Python including pycrypto and ezpycrypto but as far as I see they only offer string encryption.
After reading http://stackoverflow.com/questions/635483/what-is-the-best-way-to-implement-nested-dictionaries-in-python why is it wrong to do:
c = collections.defaultdict(collections.defaultdict(int))
in python? I would think this would work to produce
{key:{key:1}}
or am I thinking about it wrong?
hi ,
Mine is similar to this question.
http://stackoverflow.com/questions/2042342/network-path-and-variables-in-python/2042376
The only difference is my network drive has a password protect with user name and password .
I need to copy files to a samba share using python and verify it.
if i manually login in then the code works but without logging in the shutil command does not work
Thanks
Given a class such as
def MyClass
text = "hello"
number = 123
Is there a way in python to inspect MyClass an determine that it has the two attributes text and number. I can not use something like inspect.getSource(object) because the class I am to get it's attributes for are generate using SWIG (so they are hidden in .so :) ).
So I am really looking for something equivalant to Java's [Class.getDeclardFields][1]
Any help would be appreciated, otherwise I'll have to solve this problem with SWIG + JAVA instead of SWIG + Python.
I'm porting over a program of mine from python2 to python3, and I'm hitting the following error: AttributeError: 'HTTPMessage' object has no attribute 'getdate'
Here's the code:
conn = urllib.request.urlopen(fileslist, timeout=30)
last_modified = conn.info().getdate('last-modified')
This section worked under python 2.7, and so far I haven't been able to find out the correct method to get this information in python 3.1.
The full context is an update method. It pulls new files from a server down to its local database, but only if the file on the server is newer than the local file. If there's a smarter way to achieve this functionality than just comparing local and remote file timestamps, then I'm open to that as well.
I have written a Python application and would like to give my users the option of having the app automatically launch itself when the user logs in. It is important that the user is able to toggle this option on/off from within the app itself, rather than having to manually edit login scripts, so this needs to be done from within the Python code rather than from a shell script. The app is deployed on Ubuntu Linux, any suggestions for the best way of doing this?
Hi,
I am very new to Python, I need to read numbers from a file and store them in a matrix like I would do it in fortran or C;
for i
for j
data[i][j][0]=read(0)
data[i][j][1]=read(1)
data[i][j][2]=read(2)
...
...
How can I do the same in Python? I read a bit but got confused with tuples and similar things
If you could point me to a similar example it would be great
thanks
Using Python I need to insert a newline character into a string every 64 characters. In Perl it's easy:
s/(.{64})/$1\n/
How could this be done using regular expressions in Python?
Is there a more pythonic way to do it?
Hi,
I'm looking for a python library for finding the longest common substring from a set of python strings.
I'have read that it exist to way to solve this problem :
- one using suffix trees
- the other using dynamic programming.
The method implemented is not important. Otherwise, it is important to have a implementation that can be use for a set of strings and not only two strings
Thanks,
Hi,
Has anyone used scipy-cluster for python? I am trying to compile its source code with python 2.6 but I get some irrelevant errors. has someone had the same problem?
I have this Python application that gets stuck from time to time and I can't find out where.
Is there any way to signal Python interpreter to show you the exact code that he's running (somekind of stacktrace on-the-fly)?
I have a file called foobar (without .py extension). In the same directory I have another python file that tries to import it:
import foobar
But this only works if I rename the file to foobar.py. Is it possible to import a python module that doesn't have the .py extension?
I found this python plugin list but thought I'd ask if anyone has any experience with anything listed there?
I'm totally new to both python and dynamic programming languages if that makes any difference.
Hi, I am trying to send raw xml to a service in Python. I have a the address of the service and my question is how would I wrap XML in python and send it to the service. The address is in the format below.
192.1100.2.2:54239
And say the XML is:
<xml version="1.0" encoding="UTF-8"><header/><body><code><body/>
Anyone know what to do?
how can i have python move to the top of an if statement if nothing is satisfied correctly
i have a basic if/else statement like this:
print "pick a number, 1 or 2"
a = int(raw_input("> ")
if a == 1:
print "this"
if a == 2:
print "that"
else:
print "you have made an invalid choice, try again."
what i want is to prompt the user to make another choice for 'a' this if statement without them having to restart the entire program, but am very new to python and am having trouble finding the answer online anywhere.
I want to use the Twitter API in Python to lookup user ids from name using the lookup method. I have done similar requests simply using
response = urllib2.urlopen('http://search.twitter.com...')
but for this one I need authentication. I don't think I can do it through the Google python twitter API because it doesn't have the lookup method. Any ideas how can I can auth with urllib2??
I'm looking to achieve the following:
For a specific person, for example BarackObama, I'd like to get the last 100 times/tweets he was mentioned. Not his own tweets but the tweets of others containing @BarackObama.
In the end I'd like to have: the person who mentioned, location, datetime.
This content should be written to a flat file.
I've been experimenting with the Twitter API and Python, with success but haven't yet succeeded achieving the above problem.
I know there is a dev sections on the twitter website but they don't provide any example of code!!
https://dev.twitter.com/docs/api/1/get/statuses/mentions
count=100 ....
For me the scripting language or way of doing is not relevant it's the result. I just read on the internet that python and Twitter api are a good match.
Thanks a lot in advance!!
I want to use Google Chart API using javascript. (I don't want to use the python wrapper)
So how do I send data from my python code into the javascript to create graphs?