Given a list of numbers how to find differences between every (i)-th and (i+1)-th of its elements? Should one better use lambda or maybe lists comprehension?
Hi! I have a problem about release build
I'm using Visual Studio 2005. The project is worked on MFC
When I build the project what I working in debug mode, It builds done successfully.
but in release mode, Output window shows next
1Compiling resources...
1Linking...
1Generating code
and then.. it doesn't pass.
It seems like be stoped.
After 20 min ,I just canceld build.
It has been built well before.
I just added some files(.h .cpp) and resorces(.bmp), not special code
and it happened.
Do you have any idea about that?
please help me
Hi all,
how can I create a connection to excel file and view the result in vb.
I am using visual studio 2008, I have been trying to look for answers around but could not find one that teaches step by step.And what references do I need to use?
Thanks in advance.
Regards
Jason
I'm not sure if there is even anything out there to do this. Is there any libraries out there that can reword sentences to any degree of accuracy? It doesnt have to be too intelligent.
I am doing this in my code,
HOST = '192.168.1.3'
PORT = 50007
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((HOST, PORT))
query_details = {"page" : page, "query" : query, "type" : type}
s.send(str(query_details))
#data = eval(pickle.loads(s.recv(4096)))
data = s.recv(16384)
But I am continually getting EOF at the last line. The code I am sending with,
self.request.send(pickle.dumps(results))
I found a lot of links on metaclasses, and most of them mention that they are useful for implementing factory methods. Can you show me an example of using metaclasses to implement the design pattern?
configparser raises an exception if one parses a simple .properties (key/value) file wich lacks section headers; other than rolling out code myself, is there some module that allows me to do this?
I'm trying to use feedparser to get some data from yahoos weather rss. It looks like feed parser strips out the yweather namespace data:
http://weather.yahooapis.com/forecastrss?w=24260013&u=c
<yweather:condition text="Fair" code="34" temp="23" date="Wed, 19 May 2010 5:55 pm EDT" />
looks like feedparser is completely ignoring that. is there away to get it?
I have a list containing a tuples and long integers the list looks like this:
table = [(1L,), (1L,), (1L,), (2L,), (2L,), (2L,), (3L,), (3L,)]
How do i convert the table to look like a formal list?
so the output would be:
table = ['1','1','1','2','2','2','3','3']
For information purposes the data was obtained from a mysql database.
I have a list of dicts:
list = [{'title': u'Politics', 'id': 1L, 'title_url': u'Politics'},
{'id': 3L, 'title_url': u'Test', 'title': u'Test'}]
I'd like to remove the list item with title = 'Test'
What is the best way to do this given that the order of the key/value pairs change?
Thanks.
I'm trying to write a simple decorator to check the authentication of a user, and to redirect to the login page if s/he is not authenticated:
def authenticate(f):
try:
if user['authenticated'] is True:
return f
except:
redirect_to(controller='login', action='index')
class IndexController(BaseController):
@authenticate
def index(self):
return render('/index.mako' )
But this approach doesn't work. When a user is authenticated, everything is fine. But when the user is not authenticated, redirect_to() doesn't work and I am given this error:
HTTPFound: 302 Found Content-Type: text/html; charset=UTF-8 Content-Length: 0 location: /login
Thank for your help!
Hi peoples, I'm building a pdf document with reportlab, using the Paragraph class:
doc = SimpleDocTemplate(response, leftMargin=lateral_margin, rightMargin=lateral_margin,
topMargin=top_bottom_margin, bottomMargin=top_bottom_margin)
Document = []
Document.append(Paragraph("bla bla bla bla", my_style))
doc.build(Document)
Now I want to add at the end of every page a string, how can I do that??
import os
path = '/Users/Marjan/Documents/Nothing/Costco'
print path
names = os.listdir(path)
print len(names)
for name in names:
print name
Here is the code I've been using, it lists all the names in this category in terminal. There are a few filenames in this file (Costco) that don't have .html and _files. I need to pick them out, the only issue is that it has over 2,500 filenames. Need help on a code that will search through this path and pick out all the filenames that don't end with .html or _files. Thanks guys
I have a class called MODEL in which public static int theMaxFrames resides. The class is defined in its own header file. theMaxFrames is accessed by a class within the MODEL class and by one function, void set_up(), which is also in the MODEL class. The Render.cpp source file contains a function which calls a function in the Direct3D.cpp source file which in turn calls the set_up() function through a MODEL object. This is the only connection between these two source files and theMaxFrames.
When I try to compile my code I get the following error messages:
1Direct3D.obj : error LNK2001: unresolved external symbol "public: static int MODEL::theMaxFrames" (?theMaxFrames@MODEL@@2HA)
1Render.obj : error LNK2001: unresolved external symbol "public: static int MODEL::theMaxFrames" (?theMaxFrames@MODEL@@2HA)
1C:\Users\Byron\Documents\Visual Studio 2008\Projects\xFileViewer\Debug\xFileViewer.exe : fatal error LNK1120: 1 unresolved externals
I want to save a 2D array to a CSV file with row and column "header" information (like a table). I know that I could use the header argument to numpy.savetxt to save the column names, but is there any easy way to also include some other array (or list) as the first column of data (like row titles)?
Below is an example of how I currently do it. Is there a better way to include those row titles, perhaps some trick with savetxt I'm unaware of?
import csv
import numpy as np
data = np.arange(12).reshape(3,4)
# Add a '' for the first column because the row titles go there...
cols = ['', 'col1', 'col2', 'col3', 'col4']
rows = ['row1', 'row2', 'row3']
with open('test.csv', 'wb') as f:
writer = csv.writer(f)
writer.writerow(cols)
for row_title, data_row in zip(rows, data):
writer.writerow([row_title] + data_row.tolist())
I have a directory of text files that all end in the extension .txt My goal is to print the contents of the text file. I wish to be able use the wildcard *.txt to be able to specific the text file name I wish to open (I'm thinking along the lines of something like "F:\text*.txt" ?), split the lines of the text file, then print the output.
Here is an example of what I want to do, but I want to be able to change "somefile" when executing my command.
f = open('F:\text\somefile.txt', 'r')
for line in f:
print line,
I am just starting out with ADO.net Entity Framework I have mapped two tables together and receive the following error:
Error 1 Error 11010: Association End 'OperatorAccess' is not mapped. E:\Visual Studio\projects\Brandi II\Brandi II\Hospitals.edmx 390 11 Brandi II
Not sure what it is I am doing wrong
I am trying to retrieve source code from a webpage with an already issued cookie and write the source code to a txt file. If I remove the cookies=cookie portion I can retrieve the source code but I need to somehow send the cookie with the http.request.
output = open('Filler.txt', 'w+')
http = urllib3.PoolManager()
cookie =('users' , '1597413515')
r = http.request('http://google.com' , 'GET' , cookies=cookie)
output.write(r.data)
output.close()
I get a KeyError: None
Hi there,
is there any straight forward way of finding a key by knowing the value within a dictionary?
all I can think of is this:
key = [i for key,value in dict.items() if value=='value' ][0]
Any ideas?
So I have input coming in like:
12_34 5_6_8_2 4___3 1234
and the output I need from it is:
1234, 5682, 43, 1234
I'm currently working with
r'[0-9]+[0-9_]*'.replace('_','')
which (as far as I can tell) successfully rejects any input which is not a combination of numeric digits and under-scores, where the underscore cannot be the first character.
However, replacing the _ with the empty string causes 12_34 to come out as 12 and 34.
Is there a better method than 'replace' for this? Or could I adapt my regex to deal with this problem?