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.
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?
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
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]
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
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!
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]].
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
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.
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)
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.
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.
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.
Hello all, I have a python script and am wondering is there any way that I can ensure that the script run's continuously on a remote computer? Like for example, if the script crashes for whatever reason, is there a way to start it up automatically instead of having to remote desktop. Are there any other factors I have to be aware of? The script will be running on a window's machine.
Is there perl's YAPE::Regex::Explain alternative to python?
Which could do
\w+=\d+|\w+='[^']+'
to explanations like this
NODE EXPLANATION
--------------------------------------------------------------------------------
\w+ word characters (a-z, A-Z, 0-9, _) (1 or
more times (matching the most amount
possible))
--------------------------------------------------------------------------------
= '='
--------------------------------------------------------------------------------
\d+ digits (0-9) (1 or more times (matching
the most amount possible))
--------------------------------------------------------------------------------
| OR
--------------------------------------------------------------------------------
\w+ word characters (a-z, A-Z, 0-9, _) (1 or
more times (matching the most amount
possible))
--------------------------------------------------------------------------------
=' '=\''
--------------------------------------------------------------------------------
[^']+ any character except: ''' (1 or more times
(matching the most amount possible))
--------------------------------------------------------------------------------
' '\''
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?
What do the bit operators like AND(&),OR(|),XOR(^) in python do behind the screen? What do they calculate? I cannot understand the results they give when used in a program?
30&45 yields 12. How can we relate these three?
30|45 yields 63. How are these three related?
Please answer this...
Java is not my main programming language so I might be asking the obvious.
But is there a simple file-handling library in Java, like in python?
For example I just want to say:
File f = Open('file.txt', 'w')
for(String line:f){
//do something with the line from file
}
Thanks!
I was wondering how to achieve the following in python:
for( int i = 0; cond...; i++)
if cond...
i++; //to skip an run-through
I tried this with no luck.
for i in range(whatever):
if cond... :
i += 1
I have a string a and I would like to split it in half depending on its length, so I have
a-front = len(a) / 2 + len(a) % 2
this works fine in the interpreter but when i run the module from the command line python gives me a SyntaxError: can't assign to operator. What could be the issue here.
Is there any existing Python library that can validate data in Excel format? Or what kind of keyword should I use to search such an open source project? Thanks.
Hi, is there any way, in Python, to have access to an e-mail account (I'll need this for gmail but better if any works) and be able to see the number of messages in the inbox (maybe even unread messages only)?
Thank you.