w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
View result of LINQ query in watch/debugger
You cannot currently use lambda expressions in the watch list in Visual Studio. There are a couple of things you can do: Create a method that calls the desired lambda, then put that method call in your watch statement. Set the desired lambda expression to a variable, then look at the contents of that variable. Be aware that this will enumerate through the expression, and may cause side effects. I would imagine this is on the list of feature requests for VS, but MSFT has not done it yet. Hopefully this helps in the meantime.

Categories : C#

python -m details in debugger
Copied from comments to preserve the answer as an answer, (Comments are not permanently displayed): PEP 338 -- Executing modules as scripts – iMom0 1 hour ago The doc about -m flag: docs.python.org/2/using/cmdline.html#cmdoption-m – zhangyangyu 1 hour ago ah. main.py. That's what I was missing. Thanks. – numb3rs1x 1 hour ago

Categories : Python

How to tell the Python debugger to finish the program?
I would just override pdb.set_trace function, delete all breakpoints and continue pdb.set_trace = lambda : 0 The good thing is that you can do monkey patching in the debugger. vikasdhi@redpanda:~$ cat ~/tmp/test.py for i in range(1000): import pdb pdb.set_trace() vikasdhi@redpanda:~$ python ~/tmp/test.py > /home/vikasdhi/tmp/test.py(1)<module>() -> for i in range(1000): it stopped for the first time (Pdb) c > /home/vikasdhi/tmp/test.py(1)<module>() -> for i in range(1000): (Pdb) c > /home/vikasdhi/tmp/test.py(1)<module>() -> for i in range(1000): when i want to skip everything i just replace the function (Pdb) pdb.set_trace = lambda : 0 (Pdb) c vikasdhi@redpanda:~$

Categories : Python

creating your own python code fixer (not debugger, although it could be used for that)
I think the best solution here, is to use regexes. What this function does is pretty simple: you add a path to it, and it will scan that path for python files. If found one, open it in both read and write modes, and replaces all the text of pattern to repl, and then write the changes back to the file. Script: import os import re def fix_pys(path, pattern, repl): for root, dirs, files in os.walk(path): for f in files: name, ext = os.path.splitext(f) if ext == '.py': with open(os.path.join(root, f), 'r+') as py: new_py = re.sub(pattern, repl, py.read()) py.seek(0) py.write(new_py) py.truncate() Usage: fix_pys( '/Users/me/my_folder', r'type((w+))s*=

Categories : Python

Dual debugger Java + (Perl/Python) script
Yes, alter the host program (the java program ) so that it runs the perl program in a debugger You might well run into problems with the way that debuggers "attach" in different programming language environments. perl -d assumes a tty is there for interactive commands whereas java does something completely different

Categories : Java

save variable to interactive namespace from python debugger
You can accomplish this by getting a reference to the outer interpreter's stack frame, and writing to its frame globals. Given a sample module with a breakpoint that kicks us into pdb: my_module.py: def fun(arg): import pdb; pdb.set_trace() print arg Example demonstrating the basic concept: >>> import my_module >>> my_module.fun(1) > /Users/lukasgraf/src/stackoverflow/my_module.py(3)fun() -> print arg (Pdb) import sys (Pdb) sys._getframe(0) <frame object at 0x1032ab290> # this is the current frame (Pdb) sys._getframe(0).f_globals['__name__'] 'my_module' # Next outer frame (Pdb) sys._getframe(1).f_globals['__name__'] 'pdb' # etc... # In this example, frame 10 happens to be # the o

Categories : Python

View model attribute helper on attribute itself
where are these inputs coming from that you have to manually sanitize them? try this: def sanitize_attributes!(*attrs) attrs.each do |attr| dirty = self.send attr #this should mark the attribute as changed, so it's included with partial updates self.send "#{attr}=".to_sym, ActionController::Base.helpers.sanitize(dirty) #or #self.write_attribute(attr, ActionController::Base.helpers.sanitize(dirty)) end end sanitize_attributes!(:meaning, :reading)

Categories : Ruby

Launch Python debugger while simultaneously executing module as script
After experimenting with this for quite some time, it turns out that this approach actually works: python -c "import runpy; import pdb; pdb.runcall(runpy.run_module, 'somepackage.somemodule', run_name='__main__')" For some reason, the use of pdb.runcall over pdb.run is important.

Categories : Python

How do I prevent the Intellij python debugger from stepping into builtin functions?
As of right now (June 2013), this feature is not supported in PyCharm. Here is a ticket for adding the feature: http://youtrack.jetbrains.com/issue/PY-9101 If you are reading this after June 2013, then check the ticket to see if it is still in State "Open". If the ticket is still open then please vote for it! A workaround can be found here: Debugging with pycharm, how to step into project, without entering django libraries

Categories : Python

Attribute error: function object has no attribute in python
Just to get this answered: def datapaths(ipaddress, testlogfile): # Unecessary code reomved (code, val) = datapaths.listDatapaths(mylib) # Unecessary code reomved You are trying to access an attribute of a function you've defined, but most likely not set. I think you need to rexamine your code.

Categories : Python

GNAT GPS Debugger - Could not initialize the debugger
At first it sorta sounds like a path problem, but if you're able to run a debugger tutorial that's probably not the case. The behavior you're seeing if the program isn't compiled with the debug (-g) flag doesn't quite match my experience, but let's go ahead and check/set the debug flag anyway. Select Project/Edit Project_Properties Click the Switches tab. Click the Gnatmake tab. Check "Debug information". Note that a -g now shows up in the text box at the bottom of the tab page. Click OK on the dialog. Recompile your code so that it uses the changed option. Select Build/Clean/Clean All, and OK any dialog that pops up. Then do your build (you can just press F4).

Categories : Debugging

How do I inspect return values in the Winpdb Python debugger, without having to modify the source code?
Does a curses GUI count? The PuDB debugger runs in the terminal, but has a curses-based GUI. See the screenshot (don't be turned off by the blue, there are other themes as well). It has the feature you want, when you step over a return statement, it stops and shows you the return value. See the screenshot below

Categories : Python

Perl regex to match alt attribute as mandatory but sometimes alt attribute comes before src attribute and sometimes after src attribute
Does it have to be just one regex only? use Data::Dumper; my $s = q{<img rel="relfoo" src="srcfoo">}; my @m; $s =~ m{ <img s+ ( ((w+)(?{push @m, $^N})) = "( ([^"]*) (?{push @m, $^N}) )" s* )+ > }x; my %h = @m; print Dumper \%h; die "alt is mandatory.. " if !exists $h{alt}; output $VAR1 = { 'rel' => 'relfoo', 'src' => 'srcfoo' }; alt is mandatory..

Categories : Regex

Access polymorphic attribute in the view
Post has many images, and each image has a photo. So it can go like this: <% @posts.each do |p| %> <% p.images.each do |i| %> <%= image_tag(i.photo.url(:large_blog), :class => 'image') %> <% end %> <% end %>

Categories : Ruby

getting object's attribute in view from request
Yes. Simply forget about scriptlets and learn to use the JSP EL and the JSTL: <c:out value="${myObject.attr1}"/> <c:out value="${myObject.attr2}"/> Note that this assumes the object respects JavaBean conventions, and will call getAttr1() and getAttr2() on your object. The JSTL <c:out> tag escapes the HTML special characters (<, >, &, etc.).

Categories : Java

rails3 view has_many :through attribute
The issue is with the plural handling of "accessory". it was a nasty suspicion for many hours.... This issue arises rather frequently. Pony up and come up with a name that cannot be interpreted mistakenly by rails or someone, somehow, somewhere. Avoid nouns that pluralize irregularly. Moreso when dealing with foreign languages. Now class Accessorio < ActiveRecord::Base has_and_belongs_to_many :lavoraziones has_many :accessoryvolumes has_many :bozzas, through: :accessoryvolumes and <%= accessoryvolume.accessorio.nome %> runs as expected

Categories : Ruby On Rails

Backbone View Attribute Hash Not Updating
The only time the attributes hash is calculated is when the view is created, you will need to do some work yourself to update it, here is one way, initialize : function(){ this.listenTo(this.model, 'change', this.modelChange); }, modelChange : function(){ this.$el.attr(_.extend({}, _.result(this, 'attributes'))); }

Categories : Backbone Js

dynamically display different View for different ViewModel but the same attribute
You have two palces where you need decide which type to use in run time: ViewModel View On ViewModel level just use ViewModel factory, so just by an EventType/ValueType instantiates an appropriate ViewModel: private IImageSourceViewModel ProcessEvent(IEvent someEvent) { return viewModelFactory.Create(someEvent.Type) } Then on View level just use DataTemplateSelector which accepts via binding already resolved ViewModel instance and then decides which View to use: MainView XAML: <ContentControl Content="{Binding ImageSourceViewModel}" ContentTemplateSelector = "{StaticResource ImageSourceViewDataTemplateSelector}"> </ContentControl> ImageSourceViewDataTemplateSelector: private sealed class ImageSourceViewDataTemplateSelector: DataTemplateSelecto

Categories : C#

Angular - Direction attribute usable in view
Use ng-init to create a $scope property: <li ng-init="price=12.99" game="{{price}}">Game2 <span ng-show="price > 12.99">test</span></li>

Categories : Angularjs

Magento - Get product items attribute in view.phtml
I can't believe I just found the answer. Because we are not in a regular category listing we need to add the custom attributes to the collection. Here is the code: $_productCollection = $_category->getProductCollection() ->addAttributeToSelect('color');

Categories : Magento

Backbone.js: Logging a view instance only return el attribute
I did something like this and it works normally <html lang="en"> <head> <meta charset="utf-8"> <title>Backbone.js</title> <script src="jquery-1.8.1.min.js"></script> <script src="underscore.js"></script> <script src="backbone.js"></script> </head> <body> <div class="demo"> <form method ="get" id="addMenuForm" > <input type="text" value="test"/> <input type="button" name="button" value="Check it out!" /> </form> <input type="button" name="button" value="show form" id="addMenuButton" /> </div> <script> var App = Backbone.View.extend({ el : "demo", initialize: function() { addMenuForm = new AddMenuForm(); addMenuButton = new AddM

Categories : Backbone Js

I need to get back to the callers point of view after using the url attribute on twilio
Twilio evangelist here. A few ideas to start with. First, as always, you can check to the Debugger in your Twilio dashboard just to make sure there are nothing related to this there. Second, does your SIP server require you to authenticate with it in order to connect? If it does you can specify your credentials using the username and password attributes on the <Sip> noun. Lastly, you might be able to tell whats going on by hooking up the action parameter of the <Dial> verb. When Twilio tried to Dial a Sip address, we send a few extra SIP specific parameters to the URL specified on the Dial verb. One of those is call DialSipResponseCode, which is the response code we get back after sending the SIP INVITE. Hope that helps. Devin

Categories : PHP

Render Razor view to string not keeping the name attribute
You cannot set the name attribute when using the TextBox helper. That's by design. So don't try it. This helper is designed to generate markup with input field names matching your view model properties so that when the form is submitted the default model binder will be able to bind the corresponding value to the property on the view model: @Html.TextBoxFor( m => m.OrderedQuantity, new { id = "someid", data_mini = "true", type = "number", @class = "orderedQuantity removeGroupsRequired" } ) The name of the input field is OrderQuantity, so that's what you should use for your validation rules: form.validate({ rules: { OrderedQuantity: { required: true } }, messages: { OrderedQuantity: {

Categories : Asp Net Mvc

How to use standard attribute android:text in my custom view?
use this: public YourView(Context context, AttributeSet attrs) { super(context, attrs); int[] set = { android.R.attr.background, // idx 0 android.R.attr.text // idx 1 }; TypedArray a = context.obtainStyledAttributes(attrs, set); Drawable d = a.getDrawable(0); CharSequence t = a.getText(1); Log.d(TAG, "attrs " + d + " " + t); a.recycle(); } i hope you got an idea

Categories : Android

title attribute to Grid View template field
I have solved my problem by using jquery. For help who have same problem I have done following process. I have created a css class for header row th and then adding title to this th using jquery by following code. <script type="text/javascript"> $(document).ready(function () { $('#content table tr.rowH th a').attr("title", "Click to Sort"); }); </script>

Categories : Javascript

When bind view model attribute to a input textbox, it crashes in IE
Assuming that you are getting some results back of type Stakeholder and storing them in searchResults - <table data-bind="with: searchResults"> <th><tr> <td>Name</td> <td>Org Name</td> </tr></th> <tr data-bind="foreach: stakeholder"> <td data-bind="text: name"></td> <td> <input type="text" data-bind="value: orgName" /> </td> </tr> </table> Works in IE8. But since your searchResults is a KO.observableArray() I assume that you need to foreach your searchResults, but without a better picture of what you are doing it's hard to tell, here that is anyway. <table> <th><tr> <td>Name</td

Categories : Javascript

Going to specific part of a webpage using anchor name attribute by loading view in codeigniter
Ah! Found the answer at last. You just have to add the anchor to the URI in form_open() <?php echo form_open('controller/function#anchor'); ?> Reference Codeigniter Forum

Categories : PHP

editing an a has_many objects attribute in the show view. simple value increment won't update
You've got a form_for @cart and you're trying to update an attribute on a line_item. Change it to form_for line_item, get rid of your hidden field, and add @line_item.update_attributes(params[:line_item]) to LineItemController#update and it will work so long as line_items are defined as a resource. That's the easiest way. The best way may be to use accepts_nested_attributes_for :line_items in your Cart model and use fields_for in your form.

Categories : Ruby On Rails

How to know which next attribute is requested in python
No. c.someMethod is a self-contained expression; its evaluation cannot be influenced by the context in which the result will be used. If it were possible to achieve what you want, this would be the result: x = c.someMethod c.someMethod.getAttributes() # Works! x.getAttributes() # AttributeError! This would be confusing as hell. Don't try to make c.someMethod behave differently depending on what will be done with it, and if possible, don't make c.someMethod a method call at all. People will expect c.someMethod to return a bound method object that can then be called to execute the method; just define the method the usual way and call it with c.someMethod().

Categories : Python

Set attribute to Element in Python
You should be doing: ET.SubElement(root,'TextSummary').set('Status','Completed') The Etree documentation shows usage.

Categories : Python

Getting Attribute error in Python
self.entbx is created by create_widget(). You are calling reveal() -- which requires self.entbx -- before you've called create_widget(): self.reveal() self.create_widget()

Categories : Python

Python - How to get the attribute behind @property
There's no general way to do this, since a property doesn't have to simply be a proxy for a private attribute. You could have any of the following: @property def foo(self): return 4 @property def bar(self): return self._bar**2 @property def baz(self): sys.exit(1) @property def spam(self): if self._spam is None: self._spam = self._lazily_compute_spam() return self._spam If you wanted to try it anyway, you could try to get the source code of the property method with the inspect module and parse it, or decompile the bytecode, but both are terribly fragile ideas.

Categories : Python

Python CSV Has No Attribute 'Writer'
If you've set something that assigns to csv (looks like a string) then you're shadowing the module import. So, the simplest thing is to just change whatever's assigning to csv that isn't the module and call it something else... In effect what's happening is: import csv csv = 'bob' csvout = csv.writer(somefile) Remove the further assignment to csv and go from there...

Categories : Csv

launching Excel application using Python to view the CSV file , but CSV file is opening in read mode and cant view the data written on it
You need to close the csv file before you open it with Excel: with open (_csvFilename, 'wb') as _csvFile _csvFile = csv.writer(_csvFile, quoting=csv.QUOTE_ALL) _Header = ['Name']+self.makeIntoList (self.root.tss.series () [0].getAllTimes (), self.originalTimesteps + _futurePeriods) _csvFile.writerow (_Header) xl = Dispatch('Excel.Application') wb = xl.Workbooks.Open(_csvFilename) xl.Visible = True By using a with statement the open file object is automatically closed when the block indented under the statement completes. Windows doesn't like it when more than one application has a file open.

Categories : Python

Customizing view model data-annotation error : An attribute argument must be a constant expression,
You should create your own StringLength class to implement this: public class CustomStringLength : StringLengthAttribute { public CustomStringLength() { //Set your error message right here base.ErrorMessage = userOptions.GetErrorByLabel(labelCode); } } Obviously this will need to wire up to your back-end data, but, this is the general idea of how you can dynamically set the error message.

Categories : Asp Net Mvc

Get values from onclick attribute using python bs4
You can use regex for getting the data out of onclick: properties = soup.findAll('a', title=re.compile('Bedroom')) for eachproperty in properties: print re.findall("'([a-zA-Z0-9,s]*)'", eachproperty['onclick']) prints: ['Y10765227', '9884877926, 9283183326', '', 'Dealer', 'Rgmuthu'] ['L10038779', '9551154555', ',', ','] ['R10831945', '9150000747, 9282109134, 9043728565', ',', ','] ['B10750123', '9952946340', '', 'Dealer', 'Bala'] ['R10763559', '9841280752, 9884797013', '', 'Dealer', 'Senthil'] ... Hope that helps.

Categories : Python

Python: Subsetting a list according to the attribute
For your specific example, you could use a list comprehension like so: return [x for x in a_list if x.smth == 2] For your general example, you could do a similar thing: if value_to_accept is not None: return [x for x in a_list if x.smth == value_to_accept] if value_to_reject is not None: return [x for x in a_list if x.smth != value_to_reject] return []

Categories : Python

Call attribute method python
Just call it date.now() - you'll never be able to access the hour attribute of the function since it's an attribute of the object. Doing date.hour will allow you to see hour. >>> date.hour 'hour' What you should do though is set all of these properties in the __init__ function of your class. class Date(): def __init__(self, hour): self.hour = hour def now(self): print self.hour #if you will def __call__(self string): print string

Categories : Python

Set attribute on a python thread from traits
Ok, I got it: I was adding the attribute port_name before creating the instance. class Arduino(HasTraits): start_stop_capture = Button() display = Instance(TextDisplay) capture_angles = Instance(CaptureAngles) capture_angles.port_name = 'COM5' # <-- wrong: the object is not created yet ... instead of: def _start_stop_capture_fired(self): if self.capture_angles and self.capture_angles.isAlive(): self.capture_angles.wants_abort = True else: self.capture_angles = CaptureAngles() self.capture_angles.port_name = 'COM5' # <-- correct ...

Categories : Python

Python class without attribute boilerplate
Here are some recipes you can try: override __setattr__, __dict__, __slots__ and/or init. Let us know what works for you.

Categories : Python



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.