【问题标题】:What does "|" mean other that bitwise or“|”是什么意思表示其他按位或
【发布时间】:2020-12-13 19:09:24
【问题描述】:

我遇到了以下声明。除了按位或之外,| 是什么意思?

import apache_beam as beam
from apache_beam.options.pipeline_options import PipelineOptions

# argv = None  # if None, uses sys.argv
pipeline_options = PipelineOptions(argv)
with beam.Pipeline(options=pipeline_options) as pipeline:
  lines = (
      pipeline
      | beam.Create([
          'To be, or not to be: that is the question: ',
          "Whether 'tis nobler in the mind to suffer ",
          'The slings and arrows of outrageous fortune, ',
          'Or to take arms against a sea of troubles, ',
      ]))

【问题讨论】:

  • p 指的是什么?请提供Minimal, Reproducible Example :)
  • Python 中的对象可以实现按位或具有自己的含义的运算符。看起来您正在使用为该行上的 p 对象执行此操作的库。在不知道p 的类型的情况下,我们无法帮助您判断它的作用。
  • | 表示相关对象(通常是左侧的对象)想要它表示的任何含义。这看起来像是程序员被这种能力冲昏了头脑的情况。
  • @rafadeboas 它已添加到故事中。

标签: python apache-spark pyspark apache-beam


【解决方案1】:

Python 允许任何类重新定义 | 以表示它想要的任何含义。 beam.io 使用 | 作为 apply 运算符的快捷方式。结果看起来像一个 Unix 管道,它也使用|

【讨论】:

    猜你喜欢
    • 2011-09-17
    • 1970-01-01
    • 1970-01-01
    • 2012-05-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-03-26
    相关资源
    最近更新 更多