python

what exactly is random.random doing

random.shuffle(lst_shuffle, random.random) I know the latter part is an optional argument. But what does it do exactly. I don't understand what this mean. This is from the docs. random.random()¶ Return the next random floating point number in the range [0.0, 1.0). I also see this, is this what this range 0,0, 1,0 means? ...

Floating Point Concepts in Python

Why Does -22/10 return -3 in python. Any pointers regarding this will be helpful for me. ...

Oauth script: Error 401: Unauthorized

Hello! Does someone have a successful experience in using oauth script for Twitter (for example)? According to official Oauth docs obtaining an Unauthorized Request Token results in getting The Request Token and The Token Secret in the HTTP response's body. But while using this script i am getting an exception raise HTTPError(req.g...

Is it possible to add PyQt4\PySide packages on a virtualenv sandbox?

Hi i'm using virtualenv with profit on my develop environment with web.py, simplejson and other web oriented packages. I'm preparing to develop a simple python client using Qt to reuse some Api developed with web.py. Does anybody here had succesfully installed PyQt4 with virtualenv? Is it possible? I've downloaded all the binaries and h...

In memory database with socket capability

Python --> SQLite --> ASP.NET C# I am looking for an in memory database application that does not have to write the data it receives to disc. Basically, I'll be having a Python server which receives gaming UDP data and translates the data and stores it in the memory database engine. I want to stay away from writing to disc as it takes ...

PyQt Documentation

I have installed PyQt GPL v4.6.2 for Python v3.1 and Qt by Nokia v4.6.0 (OpenSource), but the documentation in PyQt is not coming up. Example docs are all blank too. Would anyone mind writing a step-by-step guide on what links to visit and what procedures must be executed in order to get text to come up for the PyQt Documentation? Edit...

What does '_' do in Django code?

Why does this Django code use _ in front of 'has favicon' has_favicon = models.BooleanField(_('has favicon')) ...

How can I get more intuitive feels about django relationships(like:Many-to-one,Many-to-many )

i use xampp(it has mysql) I was Confused on this django relationships, who can give me a code example(or text) to let me feel it intuitive .thanks (like:Einstein described the theory of relativity) ...

I've never seen 'class __proxy__' before, what does this mean(I only have seen that like def __str__)

this code is in the django.utils.functional.py class __proxy__(Promise): thanks ...

why my code only print 'bbb' once,and it does not run wrong unexpectedly.

class a: class __b__(object): print 'bbb' b=a() b.__b__() b.__b__() b.__b__() a.__b__() a.__b__() a.__b__() it print 'bbb' only once, thanks ...

python source code conversion to uml diagram

hi, please let me know how to create a uml diagram along with its equivalent documentation for the source code(.py format) using enterprise architecture 7.5 please help me find the solution, i have read the solution for the question on this website related to my topic but in vain ...

pylint PyQt4 error

I write a program : from PyQt4.QtCore import * from PyQt4.QtGui import * def main(): app = QApplication([]) button = QPushButton("hello?") button.show() app.exec_() if __name__=="__main__": main() the file name is t.py, when I run: pylint t.py in ubuntu9.10, pyqt4, I got this: pylint t.py No config file foun...

Cannot use Python 2.6 C interface anymore, but 2.5 works.

I just noticed that I cannot use the Python 2.6 dll anymore. Python 2.5 works just fine. import ctypes py1 = ctypes.cdll.python25 py2 = ctypes.cdll.python26 # ctypes.cdll.LoadLibrary("libpython2.6.so") in linux py1.Py_Initialize() py2.Py_Initialize() # segmentation fault in Linux py1.PyRun_SimpleString("print 'hello world'") # this ...

how can i get all of python Reserved Words which has 4 Underline(__str__),because django made many function with 4 '_'too

i can't Distinguish them for example in django: def __wrapper__ def __deepcopy__ def __mod__ def __cmp__ thanks ...

How do I make a simple file browser in wxPython?

Hi, I'm starting to learn both Python and wxPython and as part of the app I'm doing, I need to have a simple browser on the left pane of my app. I'm wondering how do I do it? Or at least point me to the right direction that'll help me more on how to do one. Thanks in advance! EDIT: a sort of side question, how much of wxPython do I need...

How to get alpha value of a PNG image with PIL?

How to detect if a PNG image has transparent alpha channel or not using PIL? img = Image.open('example.png', 'r') has_alpha = img.mode == 'RGBA' With above code we know whether a PNG image has alpha channel not not but how to get the alpha value? I didn't find a 'transparency' key in img.info dictionary as described at PIL's website ...

I wan to print 'eee fff {'e':'eee','f':'fff'}',how can i get it. (it is about __setattr__)

the next is my code: class a: w={} def __setattr__(self,name,value): self.w[name]=value def __getattr__(self,name): return self.w[name] b=a() b.e='eee' b['f']='fff' print b.e,b['f'],b.w #error what is the difference between b.e and b['f']. thanks ...

Selecting rows from numpy ndarray

I want to select only certain rows from a numpy array based on the value in the second column. For example, this test array has integers from 1 to 10 in second column. >>> test = numpy.array([numpy.arange(100), numpy.random.randint(1, 11, 100)]).transpose() >>> test[:10, :] array([[ 0, 6], [ 1, 7], [ 2, 10], [ 3, ...

What is the significance of a function without a 'self' argument insde a class?

class a: def b(): ... what is the Significance of b thanks class a: @staticmethod def b(): return 1 def c(self): b() print a.b() print a().b() print a().c()#error and class a: @staticmethod def b(): return 1 def c(self): return self.b() print a.b() pr...

How to use on_mouse_motion to move around a lable via pyglet?

How can one move a label around in the hello world example using the on_mouse_motion function? The docs aren't clicking for me. on_mouse-motion hello_world_example.py ...