Can you please give me a simple, and straightforward python example of sending an HTML e-mail using App Engine? Plaintext is straightforward, but I'm having difficulties with HTML tags.
I want someone to type words in the console, and autocomplete from a list when they hit "tab" key. However, raw_input won't return a string until someone hits [Enter].
How do I read characters into a variable until the user hits [Enter]?
*Note: I don't want to use import readline for autocompletion because of OS issues.
One of the ideas of Python's design philosophy is "There should be one ... obvious way to do it." (PEP 20), but that can't always be true. I'm specifically referring to (simple) if statements versus boolean evaluation. Consider the following:
if words:
self.words = words
else:
self.words = {}
versus
self.words = words or {}
With such a simple situation, which is preferable, stylistically speaking? With more complicated situations one would choose the if statement for readability, right?
So the setup is a slew of proprietary server/client Python applications running on one Linux box (the server) and a set of Windows 7 workstations (the clients). Everything is running smoothly until any of the proprietary Python packages needs updating.
For now I am using distutils eggs which are very easily updated with easy_install, but it is still a manual process which quickly becomes tedious as the number of applications and client workstations grow.
The ideal setup IMHO is to have the Python packages on the server so when a client application is launched on a workstation the client application can check to see whether its current Python packages are up-to-date. If not, the client application should download the newer Python package from the server, install it, and then launch as per normal.
Does this sounds familiar to anyone? I have tried to find alternatives myself, but as far as I can see there is no Python module offering this functionality. Does anyone have any home made solutions for this?
Is there a way in python to programmatically determine the width of the console? I mean the number of characters that fits in one line without wrapping, not the pixel width of the window.
Edit
Looking for a solution that works on Linux
Hello everybody
I'm trying to manually create the file descriptor associated with a socket in python and then loaded directly into memory with mmap. Create a file into memory with mmap is simple, but I can not find a way to associate the file with a socket.
Anyone know how?
thank you very much.
Hey
Is it possible with python to set the timezone just like this in php:
date_default_timezone_set("Europe/London");
$Year = date('y');
$Month = date('m');
$Day = date('d');
$Hour = date('H');
$Minute = date('i');
I can't really install any other modules etc as I'm using shared web hosting.
Any ideas?
How to truncate sthe string to 75 characters only in python
This is how it was done in javascript
var data="saddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddsaddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddsadddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd"
var info = (data.length > 75) ? data.substring[0,75] + '..' : data;
Hi,
I need to compare two files and redirect the different lines to third file. I know using diff command i can get the difference . But, is there any way of doing it in python ?
What Python libraries do folks use for querying Amazon product data? (Amazon Associates Web Service - used to be called E-Commerce API, or something along those lines).
Based on my research, PyAWS (http://pyaws.sourceforge.net/) seems okay, but still pretty raw (and hasn't been updated in a while). Wondering if there's an obvious canonical library that I'm just missing.
I want to run:
python somescript.py somecommand
But, when I run this I need PYTHONPATH to include a certain directory. I can't just add it to my environment variables because the directory I want to add changes based on what project I'm running. Is there a way to alter PYTHONPATH while running a script? Note: I don't even have a PYTHONPATH variable, so I don't need to worry about appending to it vs overriding it during running of this script.
wow i thought i knew python untill tonight.. what is the correct way to do something like this.. heres my code
a = ["one", "two", "three"]
b = a #here i want a complete copy that when b is changed, has absolutely no effect on a
b.append["four"]
print a #a now has "four" in it..
so basically i want to know, instead of the b = a step, how would i correctly make a copy of a list or dictionary so that when b is changed a does not change along with it.. thanks guys
Right now I am using an arduino to send data from an analog sensor to COM4. I am trying to make a python script that continuously monitors that data and looks for a certain parameter.
I tried something like this but it isn't outputing the data like I want.
import serial
port = "COM4"
ser = serial.Serial(port,9600, timeout =1)
value = 0
while 1:
value = ser.read()
print value
Hello,
Recently I needed to generate a huge HTML page containing a report with several thousand row table. And, obviously, I did not want to build the whole HTML (or the underlying tree) in memory. As result, I built the page with the old good string interpolation, but I do not like the solution.
Thus, I wonder whether there are Python templating engines that can yield resulting page content by parts.
Sorry, this is probably a terrible question. I've JUST started learning python today. I've been reading a Byte of Python. Right now I have a project for Python that involves time. I can't find anything relating to time in Byte of Python, so I'll ask you:
How can I run a block for a user specified amount of time and then break?
For example (in some pseudo-code):
time = int(raw_input('Enter the amount of seconds you want to run this: '))
while there is still time left:
#run this block
or even better:
import sys
time = sys.argv[1]
while there is still time left:
#run this block
Thanks for any help. Also, additional online guides and tutorials would be much appreciated. I really like Byte of Python. Dive into Python can't quite hold my attention, though. I suppose I should suck it up and try harder to read that one.
I have a large data set of tuples containing (time of event, latitude, longitude) that I need to visualize. I was hoping to generate a 'movie'-like xy-plot, but was wondering if anyone has a better idea or if there is an easy way to do this in Python?
Thanks in advance for the help,
--Leo
Python has string.find() and string.rfind() to get the index of a substring in string.
I wonder, maybe there is something like string.find_all() which can return all founded indexes (not only first from beginning or first from end)?
For example:
string = "test test test test"
print string.find('test') # 0
print string.rfind('test') # 15
#that's the goal
print string.find_all('test') # [0,5,10,15]
I'm wondering specifically what experienced programmers thought when they started developing in Python. I'm sure the answer depends on your background, but my own personal answer is the conversion of basically anything in the language to a True/False value in boolean contexts.
Resulting in "oddities" like:
if x:
not meaning the same thing as:
if x == True:
I understand why, but it bugs me, and I certainly had to think about it a bit when I first ran into it.
Hello,
I want to make an executable file (.exe) of my python's application.
I want to know how to do it but have this in mind:
I use a c++ dll!
Do I have to put the dll along side with the .exe or is there some other way?
Thanks in advance!
Hi, I am new to python.
I am trying to extract the text between that has specific text file:
----
data1
data1
data1
extractme
----
data2
data2
data2
----
data3
data3
extractme
----
and then dump it to text file so that
----
data1
data1
data1
extractme
---
data3
data3
extractme
---
Thanks for the help.
I have a list L of objects (for what it's worth this is in scons). I would like to create two lists L1 and L2 where L1 is L with an item I1 appended, and L2 is L with an item I2 appended.
I would use append but that modifies the original list.
How can I do this in Python? (sorry for the beginner question, I don't use the language much, just for scons)
Is there any fast method to make a transposition of a rectangular 2D matrix in Python (non-involving any library import).? Say, if I have an array X=[[1,2,3], [4,5,6]] I need an array Y which should be a transposed version of X, so Y=[[1,4],[2,5],[3,6]].
When I run some python code in NetBeans, which raises an error, the output in NetBeans just gives an error message and no further information, such as line number. Is there any way to fix that?