Identi.ca Identi.ca
  • Login
  • Public

    • Public
    • Groups
    • Featured
    • Popular

Conversation

Notices

  1. Matthew Jones Matthew Jones Python

    Anybody who how to do this in !python: "b = len(a) > 2 ? a[2] : ''"

    Saturday, 14-Nov-09 01:59:32 UTC from Gwibber
    • Marcos Diaz Marcos Diaz Python

      @matthewjones @matthewjones Since !python 2.5 this is the syntax you want: x = true_value if condition else false_value

      Saturday, 14-Nov-09 02:21:52 UTC
    • Carlo E. T. Oliveira Carlo E. T. Oliveira Python

      @matthewjones the weird and working answer for "b = len(a) > 2 ? a[2] : ''" in !python is b=[3*[''],a][len(a)>2][2], were 3 is n+1 if 2 is n

      Saturday, 14-Nov-09 17:45:23 UTC
    • Julian Julian Carlo E. T. Oliveira

      @carlotolla b = len(a) > 2 and a[2] or ''

      Saturday, 14-Nov-09 17:53:09 UTC
    • naw naw Marcos Diaz

      @matthewjones @markos the way used before 2.5 was http://www.diveintopython.org/power_of_introspection/and_or.html#d0e9975

      Saturday, 14-Nov-09 19:22:20 UTC

Site notice

  • API
  • Status

Feeds

  • Activity Streams
  • RSS 2.0
  • Atom
  • Help
  • About
  • FAQ
  • TOS
  • Privacy
  • Source
  • Version
  • Contact

Identi.ca is a microblogging service brought to you by Status.net. It runs the StatusNet microblogging software, version 1.1.0-alpha1, available under the GNU Affero General Public License.

Creative Commons Attribution 3.0 All Identi.ca content and data are available under the Creative Commons Attribution 3.0 license.

Switch to mobile site layout.

Built in Montreal