conditional-statements Questions

10

Solved

Is there a way to begin a block of code with a with statement, but conditionally? Something like: if needs_with(): with get_stuff() as gs: # do nearly the same large block of stuff, # involving...

19

Solved

Is there a way to write an IF OR IF conditional statement in a windows batch-file? For example: IF [%var%] == [1] OR IF [%var%] == [2] ECHO TRUE

4

Solved

In PHP we can check if a key exists in an array by using the function array_key_exists(). In the Twig templating language we can check if an variable or an object's property exists simply by using...
Urinalysis asked 28/11, 2012 at 14:21

6

I have a dataframe: df = pd.DataFrame({ 'col1': [0.1, 0.8, 0.2, 0.12], 'col2': [0.2, 0.9, 0.1, 0.1], 'col3': [0.3, 0.2, 0.1, 0.2], 'col4': [0.6, 0.7, 0.8, 0.9] }) col1 col2 col3 col4 0 0.10 0...
Tachistoscope asked 27/3, 2023 at 23:12

19

Solved

I would like to use conditions in my CSS. The idea is that I have a variable that I replace when the site is run to generate the right style-sheet. I want it so that according to this variable th...
Helvetii asked 15/7, 2009 at 6:20

3

Solved

I would like to notify a handler in my role by doing something like this: - name: Notify handler notify: my_handler when: this_thing_is_true|bool But Ansible just whines: ERROR! no module/actio...
Lupien asked 3/6, 2020 at 21:27

16

Solved

An alternative title might be: Check for existence of multiple rows? Using a combination of SQL and C# I want a method to return true if all products in a list exist in a table. If it can be done ...
Crypto asked 19/5, 2010 at 0:23

8

Solved

Why do some people use while(true){} blocks in their code? How does it work?
Signac asked 16/10, 2010 at 0:23

6

Solved

I'm trying to check against multiple possibilities in an if statement. The user inputs a string, and then I check that string against multiple possibilities. if (theString == "Seven" || &...
Melonie asked 19/4, 2017 at 1:28

5

Solved

I'd like to perform an atomic GET in Redis, and if the value returned is equal to some expected value, I'd like to do a SET, but I want to chain all of this together as one atomic operation. (I'm t...
Pleasure asked 12/5, 2018 at 17:59

2

Solved

I am testing a web app with cypress. I sign in in my beforeEach function. Then, in my different tests, I begin with cy.visit('mysite.com/url'). My problem is that after sign in, the website redirec...
Inextensible asked 27/10, 2020 at 11:16

5

Solved

How can I detect if the "myaccount/my-account.php" template is used on the Dashboard. Currently I use: <?php global $wp; if ( !isset($wp->query_vars['page']) ) { ?> <a href="/mein-...
Polydactyl asked 18/7, 2016 at 19:29

2

Solved

I have a DataFrame which looks like below. I am trying to count the number of elements less than 2.0 in each column, then I will visualize the result in a bar plot. I did it using lists and loops, ...

7

I want to add a volume to my service, but only if the final user gave a folder for it. Otherwise, no volume should be mounted, for the already-prepared image has valid data in a default folder. Tha...

4

Solved

Say I have a DataFrame df with date as index and some values. How can I select the rows where the date is larger than some value x? I know I can convert the index to a column and then do the sele...
Skyjack asked 6/6, 2014 at 18:52

32

So far whenever I needed to use a conditional statement within a Widget I have done the following (Using Center and Containers as simplified dummy examples): new Center( child: condition == true...
Bund asked 8/4, 2018 at 0:10

8

Solved

How do you put an "IF DEBUG" condition in a c# program so that, at run time, it will ignore a set of code if you are running in Debug mode and yet, execute a block of code if the program is not run...
Compensate asked 16/6, 2010 at 19:28

4

Solved

I'm trying to implement the following in SwiftUI: struct PersonView: View { @State private var age: Int? = 0 var body: some View { VStack { Text("Just a test") if let self.age > 0 { Tex...
Jedlicka asked 28/12, 2019 at 6:49

4

I have a script that checks the health of a pc by parsing through log files looking for indicators of compromise. If the script finds a certain event id it returns a normalized message. The end goa...
Capsize asked 11/9, 2015 at 4:53

8

Solved

How can I conditionally add 'b' => 'xyz' in the array below, in the array() statement? $arr = array('a' => abc) The ternary operator doesn't let me do it.

7

How to wait x seconds or until a condition becomes true? The condition should be tested periodically while waiting. Currently I'm using this code, but there should be a short function. for (int i ...
Mean asked 15/8, 2014 at 11:12

3

Solved

I would like to create a conditional task in Airflow as described in the schema below. The expected scenario is the following: Task 1 executes If Task 1 succeed, then execute Task 2a Else If Task...
Metonymy asked 28/4, 2017 at 10:49

4

Using jq-1.5 if I have a file of JSON that looks like [{... ,"sapm_score":40.776, ...} {..., "spam_score":17.376, ...} ...] How would I get a count of the ones where sapm_score > 40? Thanks,...
Ninepins asked 1/11, 2017 at 20:40

35

Solved

How can I check whether a string is not null and not empty? public void doStuff(String str) { if (str != null && str != "**here I want to check the 'str' is empty or not**") { ...

3

Solved

I have something like (COMPLEX_EXPRESSION_N stands for a long subquery) select ID_Operation, FirstCheck = CASE WHEN (COMPLEX_EXPRESSION_1)= 0 then 0 else 1 end, SecondCheck = CASE WHEN (COMPLE...
Dessalines asked 26/4, 2011 at 12:57

© 2022 - 2025 — McMap. All rights reserved.