Skip to content

GitLab

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
silkaj
silkaj
  • Project overview
    • Project overview
    • Details
    • Activity
    • Releases
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 153
    • Issues 153
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
  • Merge Requests 5
    • Merge Requests 5
  • CI / CD
    • CI / CD
    • Pipelines
    • Jobs
    • Schedules
  • Operations
    • Operations
    • Incidents
    • Environments
  • Packages & Registries
    • Packages & Registries
    • Package Registry
  • Analytics
    • Analytics
    • CI / CD
    • Repository
    • Value Stream
  • Snippets
    • Snippets
  • Members
    • Members
  • Collapse sidebar
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
  • clients
  • python
  • silkajsilkaj
  • Merge Requests
  • !86

Closed
Opened Aug 06, 2018 by Sébastien DA ROCHA@cebashReporter
  • Report abuse
Report abuse

WIP : Singleton example

  • Overview 5
  • Commits 5
  • Changes 5

We could use a more simple syntax:

_ud_value = None

def get_ud_value():
    if _ud_value is None:
        _ud_value = get_last_ud_value()
    return _ud_value

Every function that needs ud value calls this function. The first call get the ud value and saves it, the next call just get the saved value.

The problem is Python forbids global variables to do this, so we have to pack it in a class. Hence the syntax that is a bit more complex.

Edited Aug 06, 2018 by Moul
Assignee
Assign to
Reviewer
Request review from
0.6.0
Milestone
0.6.0
Assign milestone
Time tracking
Reference: clients/python/silkaj!86
Source branch: singleton_example