Python Forum
Using if statement without object
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Using if statement without object
#1
Hello all,

I've been using PowerShell for years but am brand new to Python. I'm trying to figure out if I can use an If statement without a specifically defined variable. For instance, the following throws an error:

import re

If re.match("he","hellostring")):
    print("match!")
In PowerShell, I could use the $() special operator to cast a statement as a variable, and I'm wondering what I need to do to make the above If statement work, or if i need to assign the re.match() statement to a variable and then put the variable in the If statement?

Apologies for any errors in this post's format, my first one on this site. Big Grin
Reply


Messages In This Thread
Using if statement without object - by vv0bbLeS - Aug-27-2018, 09:49 PM
RE: Using if statement without object - by vv0bbLeS - Aug-28-2018, 12:43 PM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020