Search Results

Search found 114 results on 5 pages for 'syntaxerror'.

Page 4/5 | < Previous Page | 1 2 3 4 5  | Next Page >

  • NO able to use Xlrd module in python

    - by user1065102
    Question: i M not able to use xlrd module though i have installed the same??? Error obtained : Traceback (most recent call last): File "D:\xlrd_1.py", line 1, in import xlrd File "D:\Python31\lib\xlrd__init__.py", line 345 u"Consolidate_Area": u"\x00", ^ SyntaxError: invalid syntax Code : import xlrd print ("hi") Some more description: 1)i m using python 3.1, 2)i have installed xlrd-0.7.1.win32.exe (md5) taken from http://pypi.python.org/pypi/xlrd/0.7.1. 3)able to see the xlrd package in python\Lib\Site-packages 4)tried copying to include file also which didnt work. Need help on this..searched stackoverflow for the same problem as well as else where i didnt find answer so posting the same Appreciate for any help on the same

    Read the article

  • Unexpected token }

    - by tann98
    i have a script, to open a model window, but it wont work. google chrome give me "Uncaught SyntaxError: Unexpected token }", but on a line that doesnt even have a closing curly brace. here is my script: function showm(id1){ window.onscroll=function(){document.getElementById(id1).style.top=document.body.scrollTop;}; document.getElementById(id1).style.display="block"; document.getElementById(id1).style.top=document.body.scrollTop; } does anybody have any ideas on this? any help is appreciated.

    Read the article

  • Unexpected token from webservice

    - by Kenneth B
    I got this little snippet where I call a Battlefield 3 stat server. If you visit this URL, which I'm calling, we'll be getting no errors: http://api.bf3stats.com/pc/server/?output=json&id=534f7035-cef8-48aa-b233-8d44a0956e68 But when I try to get the stats via Ajax call, I get: Uncaught SyntaxError: Unexpected token : ... In my console I can see that the response is coming in, as when I visit the url, but I can't get the data with the ajax call... Is there something wrong with my code??? $.ajax({ type: "GET", url: "http://api.bf3stats.com/pc/server/?output=json&id=534f7035-cef8-48aa-b233-8d44a0956e68", dataType: "jsonp", success: function(response) { console.log(response); } }); Thank you in advance...

    Read the article

  • JQuery+Java setting field value with val() + single quote

    - by Fabio K
    I have a problem setting the value of a textarea element with jquery's val(). Basically, I have a JSP file which receives a string parameter called 'text'. Java code: String text = (String) request.getParameter('text'); Now I want my textarea element to receive this text: Javascript code: $('#textarea_id').val('<%=text%>'); It works when my text doesnt contain quotes single quotes (and possibly other chars). For example, for text = test' this error happens: Uncaught SyntaxError: Unexpected token ILLEGAL $('#textarea_id').val('test''); I hope you guys understand. I need a way to encode this value... i tried using escape so the quote is replaced by %27, but after unescaping its replaced again and the error happens. Thanks!

    Read the article

  • Python: How to use code.InteractiveConsole?

    - by Rosarch
    I'm trying to use InteractiveConsole to create a new front-end for a Python interpreter. These code fragments are from me playing around with InteractiveConsole in IDLE: >>> ses = code.InteractiveConsole() >>> ses.runsource("def foo():") True >>> ses.runsource(" return 2") File "<input>", line 1 SyntaxError: 'return' outside function (<input>, line 1) False Why does it raise a syntax error? How else can I finish writing the function? Also, for something like this: >>> ses.runsource("x = 1") False >>> ses.runsource("x") 1 False How can I capture the 1 value from above? False is the return value, but 1 is written to some stream.

    Read the article

  • Error with python-setuptools doing "sudo easy_install python-graph-core"

    - by Dan
    Using easy_install, part of the python-setuptools, I get the following error: $ sudo easy_install python-graph-core [sudo] password for dan: Searching for python-graph-core Reading http://pypi.python.org/simple/python-graph-core/ Reading http://code.google.com/p/python-graph/ Reading http://code.google.com/p/python-graph/downloads/list?can=1 Reading http://code.google.com/p/python-graph/downloads/list Best match: python-graph-core 1.7.0 Downloading http://python-graph.googlecode.com/files/python-graph-core-1.7.0.tar.gz Processing python-graph-core-1.7.0.tar.gz Running python-graph-core-1.7.0/setup.py -q bdist_egg --dist-dir /tmp/easy_install-GwpYiM/python-graph-core-1.7.0/egg-dist-tmp-1yqbyV setup.py:8: Warning: 'as' will become a reserved keyword in Python 2.6 Traceback (most recent call last): File "/usr/bin/easy_install", line 8, in <module> load_entry_point('setuptools==0.6c9', 'console_scripts', 'easy_install')() File "/usr/lib/python2.5/site-packages/setuptools/command/easy_install.py", line 1671, in main with_ei_usage(lambda: File "/usr/lib/python2.5/site-packages/setuptools/command/easy_install.py", line 1659, in with_ei_usage return f() File "/usr/lib/python2.5/site-packages/setuptools/command/easy_install.py", line 1675, in <lambda> distclass=DistributionWithoutHelpCommands, **kw File "/usr/lib/python2.5/distutils/core.py", line 151, in setup dist.run_commands() File "/usr/lib/python2.5/distutils/dist.py", line 974, in run_commands self.run_command(cmd) File "/usr/lib/python2.5/distutils/dist.py", line 994, in run_command cmd_obj.run() File "/usr/lib/python2.5/site-packages/setuptools/command/easy_install.py", line 211, in run self.easy_install(spec, not self.no_deps) File "/usr/lib/python2.5/site-packages/setuptools/command/easy_install.py", line 446, in easy_install return self.install_item(spec, dist.location, tmpdir, deps) File "/usr/lib/python2.5/site-packages/setuptools/command/easy_install.py", line 476, in install_item dists = self.install_eggs(spec, download, tmpdir) File "/usr/lib/python2.5/site-packages/setuptools/command/easy_install.py", line 655, in install_eggs return self.build_and_install(setup_script, setup_base) File "/usr/lib/python2.5/site-packages/setuptools/command/easy_install.py", line 930, in build_and_install self.run_setup(setup_script, setup_base, args) File "/usr/lib/python2.5/site-packages/setuptools/command/easy_install.py", line 919, in run_setup run_setup(setup_script, args) File "/usr/lib/python2.5/site-packages/setuptools/sandbox.py", line 27, in run_setup lambda: execfile( File "/usr/lib/python2.5/site-packages/setuptools/sandbox.py", line 63, in run return func() File "/usr/lib/python2.5/site-packages/setuptools/sandbox.py", line 29, in <lambda> {'__file__':setup_script, '__name__':'__main__'} File "setup.py", line 8 except ImportError as ie: ^ SyntaxError: invalid syntax Any suggestions to what I may be doing wrong? Thanks, Dan

    Read the article

  • Selenium IDE - Passing a URL string variable into a conditional 'gotoIf' statement throws a Syntax e

    - by user318568
    I am trying to store the current url (http://example.com)in a variable and compare it with another string as a condition in the gotoIf command (part of the gotoIf extension.js): storeLocation || url gotoIf || ${url}=="http://example.com" || label When I run this seleniun ide throws this error: [error] Unexpected Exception: message -> syntax error, fileName -> chrome://selenium-ide/content/tools.js -> file:///C:/Users/David%20Cunningham/Desktop/extensions_js/extensions.js, lineNumber -> 183, stack -> eval("http://example.com==\"http://example.com\"")@:0 ("http://example.com==\"http://example.com\"","label1")@chrome://selenium-ide/content/tools.js -> file:///C:/Users/David%20Cunningham/Desktop/extensions_js/extensions.js:183 ("http://example.com==\"http://example.com\"","label1")@chrome://selenium-ide/content/selenium/scripts/htmlutils.js:60 ([object Object],[object Object])@chrome://selenium-ide/content/selenium/scripts/selenium-commandhandlers.js:310 ()@chrome://selenium-ide/content/selenium/scripts/selenium-executionloop.js:112 (6)@chrome://selenium-ide/content/selenium/scripts/selenium-executionloop.js:78 (6)@chrome://selenium-ide/content/selenium/scripts/htmlutils.js:60 , name -> SyntaxError storeLocation should return a String so why am i getting this error, what is wrong with the syntax and how do I declare this command?

    Read the article

  • expecting tASSOC in a Rails file

    - by steven_noble
    I'm sure I've done something stupid here, but I just can't see it. I call the breadcrumb method in the application view. app/helpers/breadcrumbs_helper.rb says: module BreadcrumbsHelper def breadcrumb @crumb_list = [] drominay_crumb_builder project_crumb_builder content_tag(:div, :id => "breadcrumbs", @crumb_list.map { |list_item| crumb_builder(list_item) }) end def crumb_builder(list_item) if list_item == @crumb_list.last content_tag(:span, list_item['body'], :class => list_item['crumb']) else body = ["list_item['body']", "&nbsp;&#x2192;&nbsp;"].join link_to(body, list_item['url'], :class => list_item['crumb']) end end def drominay_crumb_builder list_item = Hash.new list_item['body'] = "Drominay" list_item['url'] = "root" @crumb_list << list_item end def project_crumb_builder end end Why oh why am I getting this "expecting tASSOC" error? (And what is a tASSOC anyway?) steven-nobles-imac-200:drominay steven$ script/server => Booting Mongrel (use 'script/server webrick' to force WEBrick) => Rails 2.2.2 application starting on http://0.0.0.0:3000 => Call with -d to detach => Ctrl-C to shutdown server ** Starting Mongrel listening at 0.0.0.0:3000 ** Starting Rails with development environment... Exiting /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `gem_original_require': /Users/steven/Drominay/app/helpers/breadcrumbs_helper.rb:7: syntax error, unexpected ')', expecting tASSOC (SyntaxError) /Users/steven/Drominay/app/helpers/breadcrumbs_helper.rb:29: syntax error, unexpected $end, expecting kEND from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `require' from /Library/Ruby/Gems/1.8/gems/activesupport-2.2.2/lib/active_support/dependencies.rb:153:in `require' from /Library/Ruby/Gems/1.8/gems/activesupport-2.2.2/lib/active_support/dependencies.rb:521:in `new_constants_in' from /Library/Ruby/Gems/1.8/gems/activesupport-2.2.2/lib/active_support/dependencies.rb:153:in `require' from /Users/steven/Drominay/app/helpers/application_helper.rb:5 from /Library/Ruby/Gems/1.8/gems/activesupport-2.2.2/lib/active_support/dependencies.rb:382:in `load_without_new_constant_marking' from /Library/Ruby/Gems/1.8/gems/activesupport-2.2.2/lib/active_support/dependencies.rb:382:in `load_file' from /Library/Ruby/Gems/1.8/gems/activesupport-2.2.2/lib/active_support/dependencies.rb:521:in `new_constants_in' ... 56 levels... from /Users/steven/.gem/ruby/1.8/gems/rails-2.2.2/lib/commands/server.rb:49 from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `gem_original_require' from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `require' from script/server:3

    Read the article

  • How to setup prawn on heroku when installed as a git submodule

    - by brad
    I have a rails app that I am trying to deploy to heroku. This app generates pdfs using prawn. I installed prawn as a git submodule rather than as a gem as this is what is recommended on the prawn website (here). This has not worked well with heroku so far though. As stated on heroku's application constraints page submodules are not supported so I followed their instructions to track the submodule in the main project and tried again. This has not worked and when I access my application I get the following error: App failed to start An error happened during the initialization of your app. This may be due to a typo, wrong number of arguments, or calling a function that doesn’t exists. Check the stack trace below for specific details. Make sure the app is working locally in production mode, by running it with RAILS_ENV (for Rails apps) or RACK_ENV (for Sinatra or other rack apps) set to production. e.g. RAILS_ENV=production script/server. Original Error /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require': /disk1/home/slugs/208590_03c9c22_67f5/mnt/app/controllers/invoices_controller.rb:37: syntax error, unexpected ')' (SyntaxError) ).to_pdf(@invoice) (and then a whole lot more that I'll spare you from) The .to_pdf function described in the last line is called in a controller in exactly the way described in the prawn how-to that I linked to above so my interpretation of the error message is that prawn is not being installed/detected. Does anyone know how I can address this? I'm new to heroku so have little idea how to approach this. Is the submodule approach for prawn dead in the water from the get-go? Do I need to install it as a gem instead. I'd rather keep it as a submodule just because that works for now and I don't want to break it.

    Read the article

  • On Ruby on Rails, <%= or <% should only matter whether it is show or no show, but why will it give

    - by Jian Lin
    The following code: <div id="vote_form"> <%= form_remote_tag :url => story_votes_path(@story) do %> <%= submit_tag 'shove it' %> <% end %> </div> gives compilation error while if the first <%= is replaced with <%, then everything works. I thought they only differ by "show" or "not show", but why will it actually cause a compile error? The error is: > SyntaxError in Stories#show > > Showing > app/views/stories/show.html.erb where > line #17 raised: > > compile error C:/Software > Projects/ror/shov12/app/views/stories/show.html.erb:17: > syntax error, unexpected ')' ... > story_votes_path(@story) do ).to_s); > @output_buffer.concat ... > ^ C:/Software > Projects/ror/shov12/app/views/stories/show.html.erb:23: > syntax error, unexpected kENSURE, > expecting ')' C:/Software > Projects/ror/shov12/app/views/stories/show.html.erb:25: > syntax error, unexpected kEND, > expecting ')'

    Read the article

  • Ruby array index method not working returning NIL value

    - by Rails beginner
    Here is the error: => ["Mænd med navnet Kim", "30.094", "29.946", "-148", "Kvinder med navnet Kim", "341", "345", "4", "Mænd med navnet Kim Hansen", "1.586", "1.573", "-13", "Kvin der med navnet Kim Hansen", "5", "5", "0", "Mænd og kvinder med efternavnet Hans en", "226.040", "223.478", "-2.562"] irb(main):094:0> irb(main):095:0* @tester.index("Mænd med navnet Kim") => nil irb(main):096:0> @tester.index("Kvinder med navnet Kim") => 4 irb(main):097:0> @tester.index("Mænd med navnet Kim Hansen") => nil irb(main):098:0> @tester.index("Kvinder med navnet Kim Hansen") => 12 irb(main):099:0> @tester.index("Mænd og kvinder med efternavnet Hansen") => nil irb(main):100:0> Example tried Gsub method: <ap(&:text).map{|d| d.delete "'"}.map{|d| d.gsub("æ", "#844"} irb(main):113:1> ) SyntaxError: (irb):112: syntax error, unexpected '}', expecting ')' from C:/Ruby193/lib/ruby/gems/1.9.1/gems/railties-3.0.9/lib/rails/comman ds/console.rb:44:in `start' from C:/Ruby193/lib/ruby/gems/1.9.1/gems/railties-3.0.9/lib/rails/comman ds/console.rb:8:in `start' from C:/Ruby193/lib/ruby/gems/1.9.1/gems/railties-3.0.9/lib/rails/comman ds.rb:23:in `<top (required)>' from script/rails:6:in `require' from script/rails:6:in `<main>' <ap(&:text).map{|d| d.delete "'"}.map{|d| d.gsub("æ", "#844")} Encoding::CompatibilityError: incompatible encoding regexp match (CP850 regexp w ith UTF-8 string) from (irb):114:in `gsub' from (irb):114:in `block in irb_binding' from (irb):114:in `map' from (irb):114 from C:/Ruby193/lib/ruby/gems/1.9.1/gems/railties-3.0.9/lib/rails/comman ds/console.rb:44:in `start' from C:/Ruby193/lib/ruby/gems/1.9.1/gems/railties-3.0.9/lib/rails/comman ds/console.rb:8:in `start' from C:/Ruby193/lib/ruby/gems/1.9.1/gems/railties-3.0.9/lib/rails/comman ds.rb:23:in `<top (required)>' from script/rails:6:in `require' from script/rails:6:in `<main>'

    Read the article

  • strange syntax error in python, version 2.6 and 3.1

    - by flow
    this may not be an earth-shattering deficiency of python, but i still wonder about the rationale behind the following behavior: when i run source = """ print( 'helo' ) if __name__ == '__main__': print( 'yeah!' ) #""" print( compile( source, '<whatever>', 'exec' ) ) i get :: File "<whatever>", line 6 # ^ SyntaxError: invalid syntax i can avoid this exception by (1) deleting the trailing #; (2) deleting or outcommenting the if __name__ == '__main__':\n print( 'yeah!' ) lines; (3) add a newline to very end of the source. moreover, if i have the source end without a trailing newline right behind the print( 'yeah!' ), the source will also compile without error. i could also reproduce this behavior with python 2.6, so it’s not new to the 3k series. i find this error to be highly irritating, all the more since when i put above source inside a file and execute it directly or have it imported, no error will occur—which is the expected behavior. a # (hash) outside a string literal should always represent the start of a (possibly empty) comment in a python source; moreover, the presence or absence of a if __name__ == '__main__' clause should not change the interpretation of a soure on a syntactical level. can anyone reproduce the above problem, and/or comment on the phenomenon? cheers

    Read the article

  • whats wrong with this ruby hash?

    - by yaya3
    I'm pretty new to ruby, I keep getting the following error: in gem_original_require': ./helpers/navigation.rb:28: odd number list for Hash (SyntaxError) Any help appreciated... module Sinatra::Navigation def navigation @navigation nav = { primary[0] = { :title => "cheddar", :active => false, :children => { { :title => "cheese", :active => false }, { :title => "ham", :active => false } } }, primary[1] = { :title => "gorgonzola", :active => false, :children => { { :title => "What is the cheese?", :active => false }, { :title => "What cheese", :active => false }, { :title => "What does the cheese tell us?", :active => false, :children => { { :title => "Cheessus", :active => false }, { :title => "The impact of different cheeses / characteristics for cheese in relation to CHSE outcomes", :active => false } } } } } }

    Read the article

  • Python: Best way to check for Python version in program that uses new language features?

    - by Mark Harrison
    If I have a python script that requires at least a particular version of python, what is the correct way to fail gracefully when an earlier version of python is used to launch the script? How do I get control early enough to issue an error message and exit? For example, I have a program that uses the ternery operator (new in 2.5) and "with" blocks (new in 2.6). I wrote a simple little interpreter-version checker routine which is the first thing the script would call ... except it doesn't get that far. Instead, the script fails during python compilation, before my routines are even called. Thus the user of the script sees some very obscure synax error tracebacks - which pretty much require an expert to deduce that it is simply the case of running the wrong version of python. update I know how to check the version of python. The issue is that some syntax is illegal in older versions of python. Consider this program: import sys if sys.version_info < (2, 4): raise "must use python 2.5 or greater" else: # syntax error in 2.4, ok in 2.5 x = 1 if True else 2 print x When run under 2.4, I want this result $ ~/bin/python2.4 tern.py must use python2.5 or greater and not this result: $ ~/bin/python2.4 tern.py File "tern.py", line 5 x = 1 if True else 2 ^ SyntaxError: invalid syntax (channeling for a coworker)

    Read the article

  • Panoramio API access using AJAX - error "Origin hxxp://foo.bar is not allowed by Access-Control-Allow-Origin."

    - by Marko
    Hello there! I am currently experiencing this issue, and am wondering why...? The error message is: "XMLHttpRequest cannot load http://www.panoramio.com/wapi/data/get_photos?v=1&key=dummykey&tag=test&offset=0&length=20&minx=-30&miny=0&maxx=0&maxy=150&callback=?. Origin hxxp://foo.bar is not allowed by Access-Control-Allow-Origin. test_panoramio.html:59Uncaught SyntaxError: Unexpected token )" "hxxp://foo.bar" refers to the site I am running the script from. The "test_panoramio.html" on the site contains e.g. the following : var url = "http://www.panoramio.com/wapi/data/get_photos? v=1&key=dummykey&tag=test&offset=0&length=20&minx=- 30&miny=0&maxx=0&maxy=150&callback=?"; function myScriptFn() { if (window.XMLHttpRequest) { myAjax = new XMLHttpRequest(); if ( typeof myAjax.overrideMimeType != 'undefined') { myAjax.overrideMimeType('text/xml'); } } else if (window.ActiveXObject) { myAjax = new ActiveXObject("Microsoft.XMLHTTP"); } else { alert('The browser does not support the AJAX XMLHttpRequest!!!'); } myAjax.onreadystatechange = function() { handleResponse(); } myAjax.open('GET', url, true); myAjax.send(null); } function handleResponse() { if (myAjax.readyState == 4){ // Response is COMPLETE if ((myAjax.status == 200) || (myAjax.status = 304)) { // do something with the responseText or responseXML processResults(); }else{ alert("[handleResponse]: An error has occurred."); } } } function processResults() { myObj = eval( '(' + myAjax.responseText + ')' ); ... doSomething() ... } The Panoramio URL works if typed directly to the browser. Please could you help me with this, I am running out of hope...:( Thank you in advance, Yours Marko

    Read the article

  • java script - Cant send parameter to function from info window in google map marker info window

    - by drdigital
    I'm showing up some markers on a map. when clicked, an info window appear. this window contains 2 button each send ajax request. the problem is that when I send any thing (Except a marker parameter below) to the button onClick event it does not work. and I get the error "adminmap.html:1 Uncaught SyntaxError: Unexpected token ILLEGAL" on the first line of the HTML page not the script file at all. function handleButtonApprove(id) { //error happens here when I send any parameter except marker8(defined below) //console.log(id); $(document).ready(function () { $.ajax({ type: "POST", url: VERIFY_OBSTACLES_URL, //data: { markerID:sentID , approved:0 }, success: function (data) { alert(data); } }); }); } function handleButtonReject() { $(document).ready(function () { $.ajax({ type: "POST", url: VERIFY_OBSTACLES_URL, //data: { markerID:marker.id , approved:0 }, success: function (data) { alert(data); } }); }); } function attachInfo(marker8, num) { //var markerID = marker.get("id"); //console.log(markerID); var infowindow = new google.maps.InfoWindow({ //Here is the error , if I sent num.toString, num or any string , it does not work. If send marker8.getPosition() for example it works. May I know the reason ? content: '<div id="info_content">Matab Info</div> <button onclick="handleButtonApprove(' + num.toString() + ')">Verify</button> </br> <button onclick="handleButtonReject()">Remove</button>' }); google.maps.event.addListener(marker8, 'click', function () { infowindow.open(marker8.get('map'), marker8); }); }

    Read the article

  • Why can't I pass an argument to create this window using wxpython?

    - by somefreakingguy
    I am trying to learn how to make a GUI in python! Following an online tutorial, I found that the following code 'works' in creating an empty window: import wx from sys import argv class bucky(wx.Frame): def __init__(self, parent, id): wx.Frame.__init__(self, parent, id, 'Frame aka window', size=(300, 200)) if __name__=='__main__': app=wx.PySimpleApp() frame=bucky(parent=None,id=-1) frame.Show() app.MainLoop() That gives me a window, which is great. However, what if I want to get an argument passed onto the program to determine the window size? I thought something like this ought to do the trick: import wx from sys import argv script, x, y = argv class mywindow(wx.Frame): def __init__(self, parent, id): wx.Frame.__init__(self, parent, id, 'Frame aka window', size=(x, y)) if __name__=='__main__': app=wx.PySimpleApp() frame=mywindow(parent=None,id=-1) frame.Show() app.MainLoop() But, alas, that does not work! Nor does the raw_input() function pass on the value. I keep getting the following error: C:/Python26/pythonw.exe -u "C:/Documents and Settings/Owner/Desktop/wz.py" File "C:/Documents and Settings/Owner/Desktop/wz.py", line 8 wx.Frame.__init__(self, parent, id, 'Frame aka window', size=(x y)) ^ SyntaxError: invalid syntax Thanks for the help!

    Read the article

  • Magic function `bash ` not found

    - by inspectorG4dget
    I have a bunch of simulations that I want to run on a high-performance cluster, on which I should make reservations to get computing time. Since the reservations are bounded by time, I am developing an automation script that I can scp into the cluster and run. This script will then download the relevant simulation files, run them, and upload the results. Part of this automation script is in bash (cp, scp, etc) and the rest is in python. In order to develop this automation, I am using an IPython notebook. So far, I've coded all the python automation stuff in my IPython notebook and am trying to write the bash part of it now. However, it seems that the magic %%bash doesn't work in my IPython notebook. I get the following error when I have this code in my cell: Cell %%bash echo hi Error File "<ipython-input-22-62ec98e35224>", line 3 echo hi ^ SyntaxError: invalid syntax On a whim, I tried this: Cell %%bash print "hi" Error hi ERROR: Magic function `bash` not found. So I tried this with %%system, %%! and %%shell. But none of those work; they all give me the same error. Why is this happening? How can I fix this? Metadata: IPython 0.13.dev Python 2.7.1 Mac OS X Lion

    Read the article

  • Python raw strings and trailing back slashes.

    - by dash-tom-bang
    I ran across something once upon a time and wondered if it was a Python "bug" or at least a misfeature. I'm curious if anyone knows of any justifications for this behavior. I thought of it just now reading "Code Like a Pythonista," which has been enjoyable so far. I'm only familiar with the 2.x line of Python. Raw strings are strings that are prefixed with an r. This is great because I can use backslashes in regular expressions and I don't need to double everything everywhere. It's also handy for writing throwaway scripts on Windows, so I can use backslashes there also. (I know I can also use forward slashes, but throwaway scripts often contain content cut&pasted from elsewhere in Windows.) So great! Unless, of course, you really want your string to end with a backslash. There's no way to do that in a 'raw' string. In [9]: r'\n' Out[9]: '\\n' In [10]: r'abc\n' Out[10]: 'abc\\n' In [11]: r'abc\' ------------------------------------------------ File "<ipython console>", line 1 r'abc\' ^ SyntaxError: EOL while scanning string literal In [12]: r'abc\\' Out[12]: 'abc\\\\' So one slash before the closing quote is an error, but two slashes gives you two slashes! Certainly I'm not the only one that is bothered by this? Thoughts on why 'raw' strings are 'raw, except for slash-quote'? I mean, if I wanted to embed a single quote in there I'd just use double quotes around the string, and vice versa. If I wanted both, I'd just triple quote. If I really wanted three quotes in a row in a raw string, well, I guess I'd have to deal, but is this considered "proper behavior"?

    Read the article

  • parse xml with elementtree, custom sorting

    - by microspace
    I want to parse xml file in utf-8 and sort it by some field. Soring is made by custom alphabet (s1 from sourcecode). History of question is here: sorting of list containing utf-8 charachters. I've found how to sort xml here. Sorting work correctly, the problem is with elementtree, I must admit that it doesn't work on python3 Here is source code: #!/usr/bin/env python # -*- coding: utf-8 -*- #import xml.etree.ElementTree as ET # Python 2.5 import elementtree.ElementTree as ET s1='aáàAâÂbBcCçÇdDeéEfFgGgGhHiIîÎíiiIjJkKlLmMnNóoOöÖpPqQrRsSsStTuUûúÛüÜvVwWxXyYzZ' s2='11111122334455666aabbccddeeeeeeffgghhiijjkklllllmmnnooppqqrrsssssttuuvvwwxxyy' trans = str.maketrans(s1, s2) def unikey(seq): return seq[0].translate(trans) tree = ET.parse("tosort.xml") container = tree.find("entries") data = [] for elem in container: keyd = elem.findtext("k") data.append((keyd, elem)) print (data) data.sort(key=unikey) print (data) container[:] = [item[-1] for item in data] tree.write("sorted.xml", encoding="utf-8") Here are instructions to import elementtree module. When I import module this way :import xml.etree.ElementTree as ET, I get a message: Traceback (most recent call last): File "pcs.py", line 19, in <module> container[:] = [item[-1] for item in data] File "/usr/lib/python3.1/xml/etree/ElementTree.py", line 210, in __setitem__ assert iselement(element) AssertionError When I use this method to import: import elementtree.ElementTree as ET, I get this message: Traceback (most recent call last): File "pcs.py", line 4, in <module> import elementtree.ElementTree as ET File "/usr/local/lib/python3.1/dist-packages/elementtree/ElementTree.py", line 794, in <module> _escape = re.compile(eval(r'u"[&<>\"\u0080-\uffff]+"')) File "<string>", line 1 u"[&<>\"\u0080-\uffff]+" ^ SyntaxError: invalid syntax I use Python 3.1.3 (r313:86834, Nov 28 2010, 11:28:10). In python2.6 elementtree work without a problem. Content of tosort.xml: <xdxf> <entries> <ar><k>zaaaa</k>definition1</ar> <ar><k>saaaa</k>definition2</ar> ... ... </entries> </xdxf>

    Read the article

  • Rails select box in form decides on create action in controller?

    - by dannymcc
    Hi Everyone? I am trying to add a select box to the base of my create form that decides if an action runs from the controller...if that makes any sense? Basically the application creates a project in FreeagentCentral whenever a new project is made: def create @company = Company.find(params[:kase][:company_id]) @kase = @company.kases.create!(params[:kase]) respond_to do |format| params[:send_to_freeagent] ? @kase.create_freeagent_project(current_user) #flash[:notice] = 'Case was successfully created.' flash[:notice] = fading_flash_message("Case was successfully created.", 5) format.html { redirect_to(@kase) } format.xml { render :xml => @kase, :status => :created, :location => @kase } end end and within my form I have: <%= check_box_tag :send_to_freeagent, 1 % Create project in Freeagent? What I would like to happen, is if the select box is checked the project is sent to Freeagent. If not, the case just gets created locally as normal but without the Freeagent data being sent. If I use the above code, I get an exception caught error: SyntaxError in KasesController#new controllers/kases_controller.rb:114: syntax error, unexpected '\n' Any idea what I am doing wrong, also is it possible to make the check boxes checked as default? Thanks, Danny

    Read the article

  • Modify onclick function with jQuery

    - by Chris Barr
    I've got a button that has an onclick event in it, which was set on the back end from .NET. Beside it is a checkbox <button class="img_button" onclick="if(buttonLoader(this)){WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions('uxBtnRelease', '', true, '', 'somepage.aspx?oupid=5&fp=true', false, true))} return false;" type="button">Release</button> <input type="checkbox" checked="checked" id="myCheckbox"> When the checkbox is clicked, needs to change the value of the query string in the URL inside the onclick function of the button. So far I have this, and the idea is right, but I keep getting errors when it's run: "Uncaught SyntaxError: Unexpected token ILLEGAL" var defaultReleaseOnClick=null; $("#myCheckbox").click(function(){ var $releaseBtn = $(".img_button"); if(defaultReleaseOnClick==null) defaultReleaseOnClick=$releaseBtn.attr("onclick"); var newOnClickString = defaultReleaseOnClick.toString().replace(/&fp=[a-z]+'/i,"&fp="+this.checked); $releaseBtn.removeAttr("onclick").click(eval(newOnClickString)); }); I know it seems kinda hacky to convert the function to a string, do a replacement, and then try to convert it back to a function, but I don't know any other way to do it. Any ideas? I've set up a demo here: http://jsbin.com/asiwu4/edit

    Read the article

  • Why the HelloWorld of opennlp library works fine on Java but doesn't work with Jruby?

    - by 0x90
    I am getting this error: SyntaxError: hello.rb:13: syntax error, unexpected tIDENTIFIER public HelloWorld( InputStream data ) throws IOException { The HelloWorld.rb is: require "java" import java.io.FileInputStream; import java.io.InputStream; import java.io.IOException; import opennlp.tools.postag.POSModel; import opennlp.tools.postag.POSTaggerME; public class HelloWorld { private POSModel model; public HelloWorld( InputStream data ) throws IOException { setModel( new POSModel( data ) ); } public void run( String sentence ) { POSTaggerME tagger = new POSTaggerME( getModel() ); String[] words = sentence.split( "\\s+" ); String[] tags = tagger.tag( words ); double[] probs = tagger.probs(); for( int i = 0; i < tags.length; i++ ) { System.out.println( words[i] + " => " + tags[i] + " @ " + probs[i] ); } } private void setModel( POSModel model ) { this.model = model; } private POSModel getModel() { return this.model; } public static void main( String args[] ) throws IOException { if( args.length < 2 ) { System.out.println( "HelloWord <file> \"sentence to tag\"" ); return; } InputStream is = new FileInputStream( args[0] ); HelloWorld hw = new HelloWorld( is ); is.close(); hw.run( args[1] ); } } when running ruby HelloWorld.rb "I am trying to make it work" when I run the HelloWorld.java "I am trying to make it work" it works perfectly, of course the .java doesn't contain the require java statement. EDIT: I followed the following steps. The output for jruby -v : jruby 1.6.7.2 (ruby-1.8.7-p357) (2012-05-01 26e08ba) (Java HotSpot(TM) 64-Bit Server VM 1.6.0_35) [darwin-x86_64-java]

    Read the article

  • Python for statement giving an Invalid Syntax error with list

    - by Cold Diamondz
    I have some code in which is throwing an error (I'm using repl.it) import random students = ['s1:0','s2:0','s3:0'] while True: print'\n'*50 print'Ticket Machine'.center(80) print'-'*80 print'1. Clear Student Ticket Values'.center(80) print'2. Draw Tickets'.center(80) menu = raw_input('-'*80+'\nChoose an Option: ') if menu == '1': print'\n'*50 print'CLEARED!' students = ['s1:0','s2:0','s3:0'] raw_input('Press enter to return to the main menu!') elif menu == '2': tickets = [] print'\n'*50 times = int(raw_input('How many tickets to draw? ') for a in students: for i in range(a.split(':')[1]): tickets.append(a.split(':')[0]) for b in range(1,times+1): print str(b) + '. ' + random.choice(tickets) else: print'\n'*50 print'That was not an option!' raw_input('Press enter to return to the main menu!') But it is throwing this error: File "<stdin>", line 19 for a in students: ^ SyntaxError: invalid syntax I am planning on using this in a class, but I can't use it until the bug is fixed, also, student names have been removed for privacy reasons.

    Read the article

  • jquery getscript <script> tags

    - by user1871612
    To ask about getscript html Code as follows: <!DOCTYPE html PUBLIC "- / / W3C / / DTD XHTML 1.0 Transitional / / EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <title>jQuery GetScript</title> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script> <script type = "text / javascript "> $(document). ready(function () { $getScript ('script.js', function (jd) { $.each (test, function (index, value) { console.log (value); }); }); }); </script> </head> <body> <div id="dest"> </div> </body> </html> js (1) code are as follows: - <script type='text/javascript'> var test = []; test [0] = ['111 ', '222']; </ script> js (2) Code as follows: - var test = []; test [0] = ['111 ', '222']; The problem is as follows: - Run js (1) code will appear: - Uncaught SyntaxError: Unexpected token < No problem running js (2) Would like to ask how we can run js (1) can not go wrong Thank! Badly written, please forgive me.

    Read the article

< Previous Page | 1 2 3 4 5  | Next Page >