hello,
i wanted to do something like this but this code return list of None (i think it's because list.reverse() is reversing the list in place):
map(lambda row: row.reverse(), figure)
i tried this one, but the reversed return an iterator :
map(reversed, figure)
finally i did something like this , which work for me , but i don't ...
Hi,
I've been researching the similarities/differences between Ruby and Python generators (known as Enumerators in Ruby), and so far as i can tell they're pretty much equivalent.
However one difference i've noticed is that Python Generators support a close() method whereas Ruby Generators do not. From the Python docs the close() meth...
Specifically I'm talking about Python. I'm trying to hack something (just a little) by seeing an object's value without ever passing it in, and I'm wondering if it is thread safe to use thread local to do that. Also, how do you even go about doing such a thing?
...
I have a class that's being imported in module_x for instantiation, but first I want to override one of the class's methods to include a specific feature dynamically (inside some middleware that runs before module_x is loaded.
...
I'm trying to get the Body Mass Index (BMI) classification for a BMI value that falls within a standard BMI range - for instance, if someone's BMI were 26.2, they'd be in the "Overweight" range.
I made a list of tuples of the values (see below), although of course I'm open to any other data structure. This would be easy to do with SQL's...
Hello,
I have one main thread that does some rather CPU intensive operation. The thread has to hold a lock for all its calculations.
Then there are some other threads which occasionally require the same lock for brief amounts of time.
How can I force the main the main thread to occasionally allow the other threads to execute without s...
I have a class where I add new methods and properties dynamically. The new properties are handled by overriding __getattr__ and __setattr__ while the new methods are added directly (obj.mymethod = foo). Is there a way to make these show up if I do "help(inst)" where inst is an instance of my class? Right now I only see the methods and at...
Hi - I'm new to Ubuntu (and the Python scripts that go with it) and I've been hitting this error with the iTunesToRhythm script.
**Traceback (most recent call last):
File "/home/amylee/iTunesToRhythm.py", line 220, in <module>
main(sys.argv)
File "/home/amylee/iTunesToRhythm.py", line 48, in main
match = correlator.correlate...
hello.
i've been searching for a while for a way to handle the lock-write mechanism in( whenever user is updating , the record should be locked for the others ) . and i've been told that the web-frame work is responsible for this.
check this out :
http://serverfault.com/questions/184666/how-to-configure-apache-server
my question is :
h...
I was trying to set up a server configuration without having to rely on the tornado.options.parse_command_line() function, but it isn't working properly. It's being parsed, but then tornado just sits on it and doesn't do anything for it. Specifically, I'm using a server.conf file that looks like so:
log_file_prefix = "./logs/errors.log"...
I have some UUIDs that are being generated in my program at random, but I want to be able to extract the timestamp of the generated UUID for testing purposes. I noticed that using the fields accessor I can get the various parts of the timestamp but I have no idea on how to combine them.
...
I'd like to change the behavior of Python's list displays so that instead of producing a list, they produce a subclass of list that I've written. (Note: I don't think this is a good idea; I'm doing it for fun, not actual use.)
Here's what I've done:
old_list = list
class CallableList(old_list):
def __init__(self, *args):
...
Python 2.6
My script needs to monitor some 1G files on the ftp, when ever it's changed/modified, the script will download it to another place. Those file name will remain unchanged, people will delete the original file on ftp first, then upload a newer version. My script will checking the file metadata like file size and date modified t...
Is there a tool in python to rewrite some code which imports things such that it no longer has to import anything?
Take a library that draws a box called box.py
def box(text='Hello, World!')
draw the box magic
return
Now in another program (we'll call it warning.py) it says:
from box import box
box('Warning, water found in ...
Possible Duplicate:
What can you use Python generator functions for?
I tried to read about python generators but did not understand much about the concept as to what we can do with generators, I am new to python
please let me know
Thank you
...
Possible Duplicate:
CPython is bytecode interpreter?
My question is:
Does Python use a compiler, an interpreter or a combination of them?
...
I have
def findfreq(nltktext, atitem)
fdistscan = FreqDist(nltktext)
distlist = fdistscan.keys()
return distlist[:atitem]
which relies on FreqDist from the NLTK package, and does not work. The problem seems to be the part of the function where I try to return only the first n items of the list, using the variable atitem. S...
I'm playing around with Google Buzz API from Python,
During the OAuth process when I reach the part of authorizing the token from browser, I go to this URL https://www.google.com/buzz/api/auth/OAuthAuthorizeToken?oauth_token=..., and when I press OK, continue I expect to be directed to a page like this one http://code.google.com/apis/ac...
I have write a website,what confused me is when i run the website,first i need start the the app,
so there are 3 ways:
sudo python xxx.py
python xxx.py
xxx.py
I didn't clear with how to use each of them,the NO.3 method currently in my computer dosen't work well
...
I have a XML file which contains 100s of documents inside . Each block looks like this:
<DOC>
<DOCNO> FR940104-2-00001 </DOCNO>
<PARENT> FR940104-2-00001 </PARENT>
<TEXT>
<!-- PJG FTAG 4703 -->
<!-- PJG STAG 4703 -->
<!-- PJG ITAG l=90 g=1 f=1 -->
<!-- PJG /ITAG -->
<!-- PJG ITAG l=90 g=1 f=4 -->
Federal Register
<!-- PJG /ITAG --...