Search Results

Search found 3 results on 1 pages for 'adohertyd'.

Page 1/1 | 1 

  • Nonetype object has no attribute '__getitem__'

    - by adohertyd
    I am trying to use an API wrapper downloaded from the net to get results from the new azure Bing API. I'm trying to implement it as per the instructions but getting the runtime error: Traceback (most recent call last): File "bingwrapper.py", line 4, in <module> bingsearch.request("affirmative action") File "/usr/local/lib/python2.7/dist-packages/bingsearch-0.1-py2.7.egg/bingsearch.py", line 8, in request return r.json['d']['results'] TypeError: 'NoneType' object has no attribute '__getitem__' This is the wrapper code: import requests URL = 'https://api.datamarket.azure.com/Data.ashx/Bing/SearchWeb/Web?Query=%(query)s&$top=50&$format=json' API_KEY = 'SECRET_API_KEY' def request(query, **params): r = requests.get(URL % {'query': query}, auth=('', API_KEY)) return r.json['d']['results'] The instructions are: >>> import bingsearch >>> bingsearch.API_KEY='Your-Api-Key-Here' >>> r = bingsearch.request("Python Software Foundation") >>> r.status_code 200 >>> r[0]['Description'] u'Python Software Foundation Home Page. The mission of the Python Software Foundation is to promote, protect, and advance the Python programming language, and to ...' >>> r[0]['Url'] u'http://www.python.org/psf/ This is my code that uses the wrapper (as per the instructions): import bingsearch bingsearch.API_KEY='abcdefghijklmnopqrstuv' r = bingsearch.request("affirmative+action")

    Read the article

  • Populate struct values with function argument

    - by adohertyd
    I am working on a program and part of it requires me to create a struct called DETAILS with the fields name, age, and height. I want to populate the record with data using a function argument. When I run my code I get compiler errors. I have put the errors in comment form beside the lines it is returned for but I can't fix them. Really could do with some help here guys thanks so much. Here is my code: #include <cstdlib> #include <iostream> #include <iomanip> using namespace std; const int LEN=100; struct DETAILS { char name[LEN]; int age; double height; }; person fillperson(struct DETAILS, char[LEN], int, double); int main() { struct person David; fillperson(David, "David Greene", 38, 180.0); //deprecated conversion from string constant to char * [-Wwrite-Strings] } person fillperson(struct DETAILS, char[LEN] name, int age, double height) //expected , or ... before 'name' { cin>>David.name>>name; cin>>David.age>>age; cin>>David.height>>height; cout<<"Done"<<endl; }

    Read the article

  • ListView getting deleted onbackpress

    - by adohertyd
    I have a listview in my mainactivity that makes a call to a database to populate it. When an item on the listview is clicked it starts a new activity showing the details of the item that was clicked. When the back button is pressed the listview is not displayed again. What could be the problem? This is the entirety of my mainactivity: public class MainActivity extends ListActivity { Button bAddMod; private ModuleDB db; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); db = new ModuleDB(this); db.open(); fillList(); db.close(); bAddMod = (Button) findViewById(R.id.btnAddMod); bAddMod.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { Intent i = new Intent(MainActivity.this, AddModule.class); startActivity(i); } }); } private void fillList() { ListView lv = getListView(); Cursor curs = db.getData(); startManagingCursor(curs); MyCursorAdapter adapter = new MyCursorAdapter(getApplicationContext(), curs); lv.setAdapter(adapter); lv.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView<?> parent, View view, int position, long id){ Intent k = new Intent(MainActivity.this, ModuleDetails.class); k.putExtra("mod_id", id); startActivity(k); } }); } }

    Read the article

1