Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7500021
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T20:01:50+00:00 2026-05-29T20:01:50+00:00

This seems like a really simple question; but I can’t see how it’s actually

  • 0

This seems like a really simple question; but I can’t see how it’s actually possible. I normally fairly good my code being PEP8 compliant. 83 characters is fine type of thing. I’ve got a longish list (dictionary) comprehension combined with an or that I’m trying to take to a new-line but I can’t work out how to get the or onto the new-line.

A much simplified version is:

>>> test = {'a' : None, 'b' : None}
>>> b = ','.join([k for k in test
...               if test[k]]) or 'hello'

Whenever ( wherever ) I try to put the or 'hello' on a new-line it fails miserably; the command line interpreter and emacs’ parser don’t understand either so it may not be possible.

Is it possible to put or 'hello' on a new line and if so where would it go?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T20:01:51+00:00Added an answer on May 29, 2026 at 8:01 pm

    Enclose in parentheses. This will work.

    >>> test = {'a' : None, 'b' : None}
    >>> b = (','.join([k for k in test if test[k]])
    ...      or 'hello')
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This seems like a really simple question, but I can't find the answer anywhere.
This seems like a simple question, but I can't find it with the Stack
This seems like a really simple question but I haven't seen it answered anywhere.
This seems like it should be really simple, but I'm unable to figure this
This seems like a silly question but I would really like your comments and
Ok, so this seems like a really silly problem but I can't get my
This really seems like a bug to me, but perhaps some databinding gurus can
This seems like a noob question, but the simple answer is eluding me. I
This seems like a really simple question -- when I'm using form_for or fields_for
I feel kind of silly asking this question as it seems really simple, but

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.