python

Way to get value of this hex number

import binascii f = open('file.ext', 'rb') print binascii.hexlify(f.read(4)) f.close() This prints: 84010100 I know that I must retrieve the hex number 184 out of this data. How can it be done in python? I've used the struct module before, but I don't know if its little endian, big..whatever.. how can I get 184 from this number ...

Reinstalling python on Mac OS 10.6 with a different gcc version

I am trying to install a Python package that requires running gcc 4.2. My gcc is pointing correctly to gcc-4.2, i.e. $ gcc -v Using built-in specs. Target: i686-apple-darwin10 Configured with: /var/tmp/gcc/gcc-5664~38/src/configure --disable-checking --enable-werror --prefix=/usr --mandir=/share/man --enable-languages=c,objc,c++,obj-c+...

Intel Compiler and Python/ctypes/libffi

Hi everyone - I am having trouble building a working version of Python with ctypes using the Intel Compiler (11.1). The trouble is, that libffi under the ctypes module does not work properly when interfacing with e.g. OpenGL. Originally, libffi did not compile using the Intel Compilers as __int128_t is not defined, and I followed the w...

messed up pythonpath when using multiple interpreters

Hi there, I have a third party program that I use for remotely calling my own application and uses python 2.4. My Application is written with python 2.6. So this is the call hierarchy: 3rd party app -> calling my app by Python24 -> my app Now when calling my application via "C:\Python26\python.exe " contains a python26.zip file and all...

Your typical sheep counting regular expression in python question

at night, after saying my prayers, i typically count sheep to help me fall asleep. i want a regular expression to help me with the correct count. i want the following strings to match 0 1sheep 2sheepsheep 3sheepsheepsheep and so on. what is the regular expression for this? something like '(\d+)(sheep){\1}' if {\1} would do what i wa...

Python Console Name Customization

Usually the Python console looks like this: >>> command Is there a way to make it look like: SomeText>>> command ...

How to extract url GET parameter from <a> tag, from the full html text.

So I have an html page. It's full of various tags, most of them have sessionid GET parameter in their href attribute. Example: ... <a href="struct_view_distrib.asp?sessionid=11692390"> ... <a href="SHOW_PARENT.asp?sessionid=11692390"> ... <a href="nakl_view.asp?sessionid=11692390"> ... <a href="move_sum_to_7300001.asp?sessionid=1169239...

Importing python variables of a program after its execution.

Hello, I've written two python scripts script1.py and script2.py. I want to run script1.py from script2.py and get the content of the variables of script1 created during the execution of script1. Script1 has several functions in which the variables are created including in the main. rgds, Bruno Thank you for all your answers. I've...

Idle's Code Context in Eclipse

I find the Code Context option of IDLE to be extremely useful when working on big projects. I wanted to know if there is a similar feature for Eclipse? Edit: I would like this feature in CDT and/or PyDev. Example image: http://i38.tinypic.com/95sb39.jpg ...

suitable replacement for python expression

I want to replace the next expression with something simpler but i'm not sure what my changes impli? if not (self.permission_index_link == 0) \ or not (self.permission_index_link == 8): with if not self.permission_index_link == (0,8): ...

How can I use meta-dot (M-.) in python with emacs?

Is there an equivalent of slime for python? For example, if I position the cursor on foo() and do M-. (jump to definition) I would like to see the source definition of the function foo This should work regardless of whether foo is in 1) the local project directory 2) in some ~/.virtualenvs/bar/lib/site-packages 3) in some other p...

Python RTF Multi Column layout

Can anybody reccomend a way of generating a multi column RTF document with python, i was going to use PyRTF but i cant find any documentation on how to set up columns. i think i might need to edit the modules source any reccomendations? ...

SVG interaction in python with cairo, opengl and rsvg

Hi, I render a huge SVG file with a lot of elements with Cairo, OpenGL and rsvg. I draw svg on cairo surface via rsvg and create an OpenGL texture to draw it. Everything is fine. And now I have to interact with elements from SVG. For example, I want to guess an element by coordinates. And I want to change the background of some path in S...

Webservice with Python client

I have a application wrote in Python. Now I must run many instances of this application, but it is one problem. Many instances have one device and access to this device must be synchronised. I think that the best way to synchronise these instances is to build webservice. In which language you suggest to write webservice. Python/Django ...

Python-Check a variable is integer or not

In python how to check whether a variable is integer or not.. ...

Break/Decompose complex and compound sentences in nltk

Is there a way to decompose complex sentences into simple sentences in nltk or other natural language processing libraries? For example: The park is so wonderful when the sun is setting and a cool breeze is blowing ==> The sun is setting. a cool breeze is blowing. The park is so wonderful. ...

How to assign a local file to the FileField in Django?

I was trying to assign a file from my disk to the FileField, but I have this error: AttributeError: 'str' object has no attribute 'open' My python code: pdfImage = FileSaver() pdfImage.myfile.save('new', open('mytest.pdf').read()) and my models.py class FileSaver(models.Model): myfile = models.FileField(upload_to="files/") ...

how to make a 3d effect on bars in matplotlib?

Hi, I have a very simple basic bar's graphic like this one but i want to display the bars with some 3d effect, like this I just want the bars to have that 3d effect...my code is: fig = Figure(figsize=(4.6,4)) ax1 = fig.add_subplot(111,ylabel="Valeur",xlabel="Code",autoscale_on=True) width = 0.35 ind = np.arange(len(values)) rects ...

How to bind self events in Tkinter Text widget after it will binded by Text widget?

So, I want to bind self events after Text widget bind it and change text in widget. Usual 'bind' is called before the content in Text widget changes. Sorry for my poor English ...

AttributeError: 'file' object has no attribute 'open' in Django while assigning a local file to the FileField

Possible Duplicate: How to assign a local file to the FileField in Django? I was trying to assign a file from my disk to the FileField, but I have this error: AttributeError: 'file' object has no attribute 'open' My python code: pdfImage = FileSaver() myPdfFile = open('mytest.pdf') pdfImage.myfile.save('new', myPdfFile) a...