Hello!
I search the whole time but cannot find it.
How to show an easy latex-formula in python?
Maybe numpy is the right choice?
EDIT:
I have a python code like:
a = '\frac{a}{b}'
and want to print this in a graphical output (like matplotlib).
...
Is there any neat trick to slice a binary number into groups of five digits in python?
'00010100011011101101110100010111' => ['00010', '00110', '10111', ... ]
Edit:
I want to write a cipher/encoder in order to generate "easy to read over the phone" tokens. The standard base32 encoding has the following disadvantages:
Potential to gen...
So, I only realised today that __new__ is deprecated for receiving arguments, as of python 2.6 (it isn't mentioned in the documentation, which is also not true in terms of the behavior of __new__ calling __init__ as far as I can see). This means my functional code has started raising warnings, and I want to rid myself of them. But I can'...
The Python 2.6 OS X installer didn't support 64 bit architectures, necessitating some chicanery to get mod_wsgi, Python 2.6 and Apache2 working on 10.5.
However, the Python 2.7 OS X installer does build a 'fat' Python install, so I'd like to know if anyone's tried this setup before I ditch my current Python 2.6 local setup, rebuild mod_...
I've created two uis using the Qt Designer, imported them into my script and set them in the normal way using the setupUi() method. When a button is clicked, and the appropriate method is executed, the new ui is loaded, but all of the widgets and connections from the old one persist.
What is the proper way to remove the connections and ...
I have a paragraph of help information that I would like to display in a window with an "ok" button at the bottom. My issue is formatting...I want to be able to simply set the paragraph equal to a variable and then send that variable to a message box widget. By default, it formats laterally and in a very ugly manner. Any advice?
def abo...
Here is what I have so far
text = "Hello world. It is a nice day today. Don't you think so?"
re.findall('\w{3,}\s{1,}\w{3,}',text)
#['Hello world', 'nice day', 'you think']
The desired output would be ['Hello world', 'nice day', 'day today', 'today Don't', 'Don't you', 'you think']
Can this be done with a simple regex pattern?
...
With ActiveState Python comes a win32api module. I need to implement something that monitors directories recursively for file-changes. Actually there's an example in the MSDN library using C. I don't know whether the win32api bindings are sufficient for something like this.
Can I import this into a Python project? Because it may be easi...
Curious if there are any higher level frameworks that attempt to wrap Tkinter? For example, wxPython is wrapped by the Dabo framework (http://dabodev.com/) and PythonCard.
Motivation: We've recently moved to Python 2.7 (Windows) and are very impressed with the new ttk (Tile) support which allows one to build professional quality, platfo...
I have a very simple table(mapped as AuthToken class), consisting of a string ('token'), and a userid (foreign key to another table), with 'user' as relation ( = class User)
session.query(AuthToken.user).one() gives back the token, and the userid (as a tuple), but not the user object.
Does anybody know why?
thanks!
...
I am embedding Python into my C++ program, and have used PyRun_SimpleString quite effectively but now am having trouble.
What I have done is loaded a python.py file a std::string but am now having troubles running it. PyRun_SimpleFileEx didn't seem to do the trick either so some help would be great!
std::string content;
if(!ail...
Two part question. I am trying to download multiple archived Cory Doctorow podcasts from the internet archive. The old one's that do not come into my iTunes feed. I have written the script but the downloaded files are not properly formatted.
Q1 - What do I change to download the zip mp3 files?
Q2 - What is a better way to pass the varia...
The goal is to read through html files and change all instances of MyWord to Myword; except, must NOT change the word if it is found inside or as part of a path, file name or script:
href="..."
src="..."
url(...)
class="..."
id="..."
script inline or linked (file name) --> <script ...></script>
styles inline or linked (file name) --> ...
Vim works fine for all other languages, but word detection seems wonky in python. For example, in the following snippet, with the cursor on the 'h' in shutil, I would expect prssing the w key to advance me to the period, instead I get moved to the "'" in front of export.
shutil.copytree(os.path.join('export', 'app'), os.path.join('expor...
I've written a program to check if my thought about solution on paper is right (and it is).
The task: how many zeros is in the back of multiplication of all numbers from 10 to 200.
It is 48 and it is a simple to calculate manually.
I never write on python seriously and this is what I get:
mul = 1
for i in range(10, 200 + 1):
mul ...
Is there a function to test floating point approximate equality in python? Something like,
def approx_equal(a, b, tol):
return abs(a - b) < tol
My use case is similar to how Google's C++ testing library, gtest.h, defines EXPECT_NEAR.
Here is an example:
def bernoulli_fraction_to_angle(fraction):
return math.asin(sqrt(frac...
I need to get the location of the home directory of the current logged-on user. Currently, I've been using the following on Linux:
os.getenv("HOME")
However, this does not work on Windows. What is the correct cross-platform way to do this?
...
I need some pointers or a practical example on how to encrypt an int to another int, and a secret key would be required to decrypt the value.
Something like:
encrypt(1, "secret key") == 67123571122
decrypt(67123571122, "secret key") == 1
This guy asks pretty much the same question: http://stackoverflow.com/questions/3131193/symmetric...
Disclaimer: I'm looking for a Python 2.6 solution, if there is one.
I'm looking for a function that returns a single value when passed a single value, or that returns a sequence when passed multiple values:
>>> a = foo(1)
2
>>> b, c = foo(2, 5)
>>> b
3
>>> c
6
To be clear, this is in an effort to make some function calls simply look ...
Hi,
I work with a team that develops MPI-based C++ numerical applications. The group uses cxxtest for constructing individual unit tests or small suites, but 1) there are some complications aggregating across directories with cxxtest's usual features and 2) there are some integration tests that are simply easier to implement "from the ou...