Getting output displayed for a each single line Python IDLE - spyder

I am new to Python, and I am currently doing an online course on "Automate the Boring stuff with Python" on udemy.com. I have a very basic problem, and that's as you can see in the highlighted portion of the following screenshot:
Displayed output in blue
The author of this online course just presses some keyboard key on a particular line and gets the out the output displayed in blue for haRegex.search. But in my case when I press enter I don't see such an output upon pressing the enter key. Previously I used to use Spyder, and get single line execution by simply pressing F9, and the the console showed the output as OUT:abcd. But, now since updating to Spyder 4.1.3, Spyder won't display the output in the console window for a single line upon pressing F9. So, I decided using Python IDLE as suggested in the course, so can someone please guide as to how can execute a single line and get its output displayed in blue as shown in the screenshot? My code is as follows:
>>> haRegex = re.compile(r'(Ha)(3)')
>>> haRegex.search('He said "HaHaHa"')
>>>

You finish entering a line by hitting the Enter key. If the code is complete, it executes. If not, you must enter more lines. If you enter a compound statement, with a header ending with ':', you must enter an extra blank line.
If the result of execution is 'None', nothing is printed and '>>>' is printed. Otherwise the result is printed. In your example, haRegex does not match the search string, even if you think it does, so nothing is printed. Use re 'Ha' and there will be a match. In 3.9, the result is <re.Match object; span=(9, 11), match='Ha'>.
The Shell output color is set by the current syntax highlight theme. For black on white normal text, it is currently blue, as in the screenshot. To check, Select Options => Configure IDLE, then the Highlights tab, and look at the sample. If you are not satisfied with any built-in theme, make a custom theme you like better.

Related

MS-Access VBA, how do you keep a textbox active after SetFocus and selecting the text?

The plan:
I have a single form with a text box that I type a serial number into. [intUID]
The subforms on this same form use this to query and display related information. After I typed a serial in, I needed to refresh to get the subforms to requery, see code below. This works fine. I then set focus back into the serial number text box, ready for the next entry. This also works fine.
The rub:
I want the text box to stay fully selected when I get focus set back to it. That way, when the next serial is entered, it deletes the old one. My code does this (can be seen stepping through the code) until the "End Sub" when it unselects it!
Private Sub intUID_AfterUpdate()
'Refresh sub forms
Forms![frmMain]![q_AG_CenterLines_X subform].Form.Requery
Forms![frmMain]![q_AG_CenterLines_Y subform].Form.Requery
'Set focus back on the barcode
Forms![frmMain]![txtSchedule].SetFocus
Forms![frmMain]![intUID].SetFocus
'Select all the text in [intUID]
Forms![frmMain]![intUID].SelStart = 0
Forms![frmMain]![intUID].SelLength = Len(Forms![frmMain]![intUID])
End Sub

Going back up a line in psql shell

Does anyone know a short cut to going back up a line in psql? I've tried ending with ); and then hitting the up arrow. I can retrieve the line of code that I want and then correct it, but then what? The initial mistake prevented me from CREATING A TABLE, so do I recreate the remaining lines of code from this point forward to finish creating the table. I'm trying to avoid retyping 10 lines of information. I'm using the postgres database and the instructor accomplishing this with very little effort; however, I cannot see the commands he is using to recreate several lines of text which a appear to use only one key. If you look at 52:00 - 53:00 on the instructional video timeline you will see what I mean. After he ends the code with ); He immediately recreates the previous block of code. How does he do this?
Video Link
https://www.youtube.com/watch?v=qw--VYLpxG4
They just cut out parts of the video. No big magic there.
But you could use \e to start your default editor containing the last command you sent. That may be the most efficient way to do this.

Skip "Capture Page Screenshot" for some keywords

I'm writing test cases in Robot Framework using AppiumLibrary.
I'm importing AppiumLibrary with the following code to get a screenshot whenever something goes wrong:
AppiumLibrary.__init__(self, run_on_failure="Capture Page Screenshot")
Is there a way to NOT take a screenshot for a specific keyword? This keyword will for example create 15 screenshots (if it's not able to find Donald):
Wait Until Keyword Succeeds 30 seconds 2 seconds Element Text Should Be Username Donald
There is nothing built-in to do what you want. There are many solutions, however.
One solution would be to turn off capturing the keyword (using register keyword to run on failure) immediately before calling wait until keyword succeeds. You could then call wait until keyword succeeds, and then turn capturing back on afterwards.
Or, you can register your own custom keyword instead of Capture page screenshot. Your own keyword can use whatever logic it wants to determine whether to capture screenshots or not. For example, it could look for a global variable that tells it whether to capture or not.
You could also write your own keyword to use in place of wait until keyword succeeds which also uses one of the other two solutions.
For example, create a keyword named wait until element contains text which turns off the capturing, runs wait until keyword succeeds, and then turns it back on. Then, in your test you still just have a single statement:
wait until element contains text Username Donald
Register Keyword To Run On Failure NONE
${Status} Run Keyword And Return Status Wait Until Keyword Succeeds 30 seconds 2 seconds Element Text Should Be Username Donald
Register Keyword To Run On Failure Capture Page Screenshot
IF ${Status}==False
Element Text Should Be Username Donald
END
-Lets Walkthrough whats happening in the above code snippet
Register Keyword To Run On Failure NONE (To avoid multiple
screenshots when Element Text Should Be keyword fails in the
next line )
After waiting for 30 seconds it will return status If the keyword passes it returns pass and if it fails it returns fails and gets stored in status variable (Remember no screenshots are generated in this process since we turned off screenshots in point 1.)
Again setting back Capture Page Screenshot Keyword on Failure to take screenshot.
Lastly one more time it will run Element Text Should Be and if it fails it generates a screenshot and keyword fails.(Since ${Status}==False that means it will run only if Wait Until Keyword Succeeds keyword fails otherwise this IF block will not run since our keyword already passed)

Alter Xcode 7 autofill behaviors

With the latest build, or maybe including the builds prior to beta 7.5 I just never noticed, I'm getting annoyed with a little autofill feature Apple implemented for substitute tokens and their objects when creating log messages. I haven't really noticed this with class methods or instance methods or autocompleting anything else really, so far.
Before, in Xcode 6, this would display:
Ahhhhh, nice & crisp. As you can see, everything suffixing the user input is opportunity for autofill. All I had to do was press tab[enter] once to autofill 'error' and include the closing parenthesis, then it would automatically place my cursor after the closing parenthesis, hence ALL I had to do was type a ; for that statement to be complete and I was happy :)
Now, this displays :
Ehhhhh, troublesome & redundant. As you can see in this example, it includes an additional quotation mark. Now when I press tab to autofill 'error', it just autofills 'error' and places the cursor before the closing parenthesis. So it looks like this:
NSLog(#"%#", error|)
And if I were to press tab to go to the next sub word that needs autocomplete it will just indent the closing parenthesis:
NSLog(#"%#", error )
So essentially, I have to either move it with my mouse or press → and then and only then, I'll be able to enter a ;. Side note - pressing ↵ to autofill results in the same behavior as described.
I am a fast typer, don't want to say my speed because I don't want it to rub off the wrong way but it's 70+wpm, so this irritates me, especially since I've been used to a way for so long. Any way to correct the behavior?
I have tried turning off Enable type-over completions in the Xcode preferences pane, but it still places the cursor before the closing parenthesis.
printf resorts to the same behavior with Xcode 7.5

special character coming when i am using & and p

I dont know what exactly i have to type in title for this ,i tried my best
anyway coming to topic
I am making one acc checker for that purpose ,i am sending user and pass from my bsskinedit1 and bsskinedit2
here is my code
s:='http:\\site.com..premlogin='+bsskinedit.text+'&password='+bsskinedit2.text
but it giving some error ,then i used showmessage whats wrong with it then i came with strange result
see below
observer after 4 & and p combining together and appearing as a some new symbol :(
can any one tell me why its coming like this ?
Your code (where you build the URL) is most likely correct (I guess the above has some typos?!), but when you display the URL in a label for instance, the & character is treated as indicator for an accelerator key.
By Windows design, accelerator keys
enable the user to access a menu
command from the keyboard by pressing
Alt along the appropriate letter,
indicated in your code by the
preceding ampersand (&). The character
after the and sign (&) appears
underlined in the menu.
If you want to display the & character itself, you have to set your string variable to &&.
By placing two ampesands together - you state that the character following the first one is not used as the accelerator - rather you actually want to get it (only one) displayed.
Just use your debugger if you want to see the real value that your string variables have, don't output them to a message box or the like... It may have side effects, as you can see.
Regarding the URL you build: I can't possibly know how it has to be correctly, but at least you should use the right slashes!
s := 'http://site.com...'
(All quotes from delphi.about.com)
In addition to what Mef said, you can use OutputDebugString to add your string to the event log in its raw form, so you don't need to modify it before displaying it. Delphi should capture those strings automatically if you're running from the debugger. If you aren't running it from Delphi you can use DebugView instead, which captures the messages from any running applications.

Resources