Python.py
made by https://0x3d.site
Thingswe have.
GitHub - pytransitions/transitions: A lightweight, object-oriented finite state machine implementation in Python with many extensionsA lightweight, object-oriented finite state machine implementation in Python with many extensions - pytransitions/transitions
Visit Site
GitHub - pytransitions/transitions: A lightweight, object-oriented finite state machine implementation in Python with many extensions
transitions
A lightweight, object-oriented state machine implementation in Python with many extensions. Compatible with Python 2.7+ and 3.0+.
Installation
pip install transitions
... or clone the repo from GitHub and then:
python setup.py install
Table of Contents
- Quickstart
- Non-Quickstart
Quickstart
They say a good example is worth 100 pages of API documentation, a million directives, or a thousand words.
Well, "they" probably lie... but here's an example anyway:
from transitions import Machine
import random
class NarcolepticSuperhero(object):
# Define some states. Most of the time, narcoleptic superheroes are just like
# everyone else. Except for...
states = ['asleep', 'hanging out', 'hungry', 'sweaty', 'saving the world']
def __init__(self, name):
# No anonymous superheroes on my watch! Every narcoleptic superhero gets
# a name. Any name at all. SleepyMan. SlumberGirl. You get the idea.
self.name = name
# What have we accomplished today?
self.kittens_rescued = 0
# Initialize the state machine
self.machine = Machine(model=self, states=NarcolepticSuperhero.states, initial='asleep')
# Add some transitions. We could also define these using a static list of
# dictionaries, as we did with states above, and then pass the list to
# the Machine initializer as the transitions= argument.
# At some point, every superhero must rise and shine.
self.machine.add_transition(trigger='wake_up', source='asleep', dest='hanging out')
# Superheroes need to keep in shape.
self.machine.add_transition('work_out', 'hanging out', 'hungry')
# Those calories won't replenish themselves!
self.machine.add_transition('eat', 'hungry', 'hanging out')
# Superheroes are always on call. ALWAYS. But they're not always
# dressed in work-appropriate clothing.
self.machine.add_transition('distress_call', '*', 'saving the world',
before='change_into_super_secret_costume')
# When they get off work, they're all sweaty and disgusting. But before
# they do anything else, they have to meticulously log their latest
# escapades. Because the legal department says so.
self.machine.add_transition('complete_mission', 'saving the world', 'sweaty',
after='update_journal')
# Sweat is a disorder that can be remedied with water.
# Unless you've had a particularly long day, in which case... bed time!
self.machine.add_transition('clean_up', 'sweaty', 'asleep', conditions=['is_exhausted'])
self.machine.add_transition('clean_up', 'sweaty', 'hanging out')
# Our NarcolepticSuperhero can fall asleep at pretty much any time.
self.machine.add_transition('nap', '*', 'asleep')
def update_journal(self):
""" Dear Diary, today I saved Mr. Whiskers. Again. """
self.kittens_rescued += 1
@property
def is_exhausted(self):
""" Basically a coin toss. """
return random.random() < 0.5
def change_into_super_secret_costume(self):
print("Beauty, eh?")
There, now you've baked a state machine into NarcolepticSuperhero
. Let's take him/her/it out for a spin...
>>> batman = NarcolepticSuperhero("Batman")
>>> batman.state
'asleep'
>>> batman.wake_up()
>>> batman.state
'hanging out'
>>> batman.nap()
>>> batman.state
'asleep'
>>> batman.clean_up()
MachineError: "Can't trigger event clean_up from state asleep!"
>>> batman.wake_up()
>>> batman.work_out()
>>> batman.state
'hungry'
# Batman still hasn't done anything useful...
>>> batman.kittens_rescued
0
# We now take you live to the scene of a horrific kitten entreement...
>>> batman.distress_call()
'Beauty, eh?'
>>> batman.state
'saving the world'
# Back to the crib.
>>> batman.complete_mission()
>>> batman.state
'sweaty'
>>> batman.clean_up()
>>> batman.state
'asleep' # Too tired to shower!
# Another productive day, Alfred.
>>> batman.kittens_rescued
1
While we cannot read the mind of the actual batman, we surely can visualize the current state of our NarcolepticSuperhero
.
Have a look at the Diagrams extensions if you want to know how.
The non-quickstart
A state machine is a model of behavior composed of a finite number of states and transitions between those states. Within each state and transition some action can be performed. A state machine needs to start at some initial state. When using transitions
, a state machine may consist of multiple objects where some (machines) contain definitions for the manipulation of other (models). Below, we will look at some core concepts and how to work with them.
Some key concepts
-
State. A state represents a particular condition or stage in the state machine. It's a distinct mode of behavior or phase in a process.
-
Transition. This is the process or event that causes the state machine to change from one state to another.
-
Model. The actual stateful structure. It's the entity that gets updated during transitions. It may also define actions that will be executed during transitions. For instance, right before a transition or when a state is entered or exited.
-
Machine. This is the entity that manages and controls the model, states, transitions, and actions. It's the conductor that orchestrates the entire process of the state machine.
-
Trigger. This is the event that initiates a transition, the method that sends the signal to start a transition.
-
Action. Specific operation or task that is performed when a certain state is entered, exited, or during a transition. The action is implemented through callbacks, which are functions that get executed when some event happens.
Basic initialization
Getting a state machine up and running is pretty simple. Let's say you have the object lump
(an instance of class Matter
), and you want to manage its states:
class Matter(object):
pass
lump = Matter()
You can initialize a (minimal) working state machine bound to the model lump
like this:
from transitions import Machine
machine = Machine(model=lump, states=['solid', 'liquid', 'gas', 'plasma'], initial='solid')
# Lump now has a new state attribute!
lump.state
>>> 'solid'
An alternative is to not explicitly pass a model to the Machine
initializer:
machine = Machine(states=['solid', 'liquid', 'gas', 'plasma'], initial='solid')
# The machine instance itself now acts as a model
machine.state
>>> 'solid'
Note that this time I did not pass the lump
model as an argument. The first argument passed to Machine
acts as a model. So when I pass something there, all the convenience functions will be added to the object. If no model is provided then the machine
instance itself acts as a model.
When at the beginning I said "minimal", it was because while this state machine is technically operational, it doesn't actually do anything. It starts in the 'solid'
state, but won't ever move into another state, because no transitions are defined... yet!
Let's try again.
# The states
states=['solid', 'liquid', 'gas', 'plasma']
# And some transitions between states. We're lazy, so we'll leave out
# the inverse phase transitions (freezing, condensation, etc.).
transitions = [
{ 'trigger': 'melt', 'source': 'solid', 'dest': 'liquid' },
{ 'trigger': 'evaporate', 'source': 'liquid', 'dest': 'gas' },
{ 'trigger': 'sublimate', 'source': 'solid', 'dest': 'gas' },
{ 'trigger': 'ionize', 'source': 'gas', 'dest': 'plasma' }
]
# Initialize
machine = Machine(lump, states=states, transitions=transitions, initial='liquid')
# Now lump maintains state...
lump.state
>>> 'liquid'
# And that state can change...
# Either calling the shiny new trigger methods
lump.evaporate()
lump.state
>>> 'gas'
# Or by calling the trigger method directly
lump.trigger('ionize')
lump.state
>>> 'plasma'
Notice the shiny new methods attached to the Matter
instance (evaporate()
, ionize()
, etc.).
Each method triggers the corresponding transition.
Transitions can also be triggered dynamically by calling the trigger()
method provided with the name of the transition, as shown above.
More on this in the Triggering a transition section.
States
The soul of any good state machine (and of many bad ones, no doubt) is a set of states. Above, we defined the valid model states by passing a list of strings to the Machine
initializer. But internally, states are actually represented as State
objects.
You can initialize and modify States in a number of ways. Specifically, you can:
- pass a string to the
Machine
initializer giving the name(s) of the state(s), or - directly initialize each new
State
object, or - pass a dictionary with initialization arguments
The following snippets illustrate several ways to achieve the same goal:
# import Machine and State class
from transitions import Machine, State
# Create a list of 3 states to pass to the Machine
# initializer. We can mix types; in this case, we
# pass one State, one string, and one dict.
states = [
State(name='solid'),
'liquid',
{ 'name': 'gas'}
]
machine = Machine(lump, states)
# This alternative example illustrates more explicit
# addition of states and state callbacks, but the net
# result is identical to the above.
machine = Machine(lump)
solid = State('solid')
liquid = State('liquid')
gas = State('gas')
machine.add_states([solid, liquid, gas])
States are initialized once when added to the machine and will persist until they are removed from it. In other words: if you alter the attributes of a state object, this change will NOT be reset the next time you enter that state. Have a look at how to extend state features in case you require some other behaviour.
Callbacks
But just having states and being able to move around between them (transitions) isn't very useful by itself. What if you want to do something, perform some action when you enter or exit a state? This is where callbacks come in.
A State
can also be associated with a list of enter
and exit
callbacks, which are called whenever the state machine enters or leaves that state. You can specify callbacks during initialization by passing them to a State
object constructor, in a state property dictionary, or add them later.
For convenience, whenever a new State
is added to a Machine
, the methods on_enter_«state name»
and on_exit_«state name»
are dynamically created on the Machine (not on the model!), which allow you to dynamically add new enter and exit callbacks later if you need them.
# Our old Matter class, now with a couple of new methods we
# can trigger when entering or exit states.
class Matter(object):
def say_hello(self): print("hello, new state!")
def say_goodbye(self): print("goodbye, old state!")
lump = Matter()
# Same states as above, but now we give StateA an exit callback
states = [
State(name='solid', on_exit=['say_goodbye']),
'liquid',
{ 'name': 'gas', 'on_exit': ['say_goodbye']}
]
machine = Machine(lump, states=states)
machine.add_transition('sublimate', 'solid', 'gas')
# Callbacks can also be added after initialization using
# the dynamically added on_enter_ and on_exit_ methods.
# Note that the initial call to add the callback is made
# on the Machine and not on the model.
machine.on_enter_gas('say_hello')
# Test out the callbacks...
machine.set_state('solid')
lump.sublimate()
>>> 'goodbye, old state!'
>>> 'hello, new state!'
Note that on_enter_«state name»
callback will not fire when a Machine is first initialized. For example if you have an on_enter_A()
callback defined, and initialize the Machine
with initial='A'
, on_enter_A()
will not be fired until the next time you enter state A
. (If you need to make sure on_enter_A()
fires at initialization, you can simply create a dummy initial state and then explicitly call to_A()
inside the __init__
method.)
In addition to passing in callbacks when initializing a State
, or adding them dynamically, it's also possible to define callbacks in the model class itself, which may increase code clarity. For example:
class Matter(object):
def say_hello(self): print("hello, new state!")
def say_goodbye(self): print("goodbye, old state!")
def on_enter_A(self): print("We've just entered state A!")
lump = Matter()
machine = Machine(lump, states=['A', 'B', 'C'])
Now, any time lump
transitions to state A
, the on_enter_A()
method defined in the Matter
class will fire.
You can make use of on_final
callbacks which will be triggered when a state with final=True
is entered.
from transitions import Machine, State
states = [State(name='idling'),
State(name='rescuing_kitten'),
State(name='offender_gone', final=True),
State(name='offender_caught', final=True)]
transitions = [["called", "idling", "rescuing_kitten"], # we will come when called
{"trigger": "intervene",
"source": "rescuing_kitten",
"dest": "offender_gone", # we
"conditions": "offender_is_faster"}, # unless they are faster
["intervene", "rescuing_kitten", "offender_caught"]]
class FinalSuperhero(object):
def __init__(self, speed):
self.machine = Machine(self, states=states, transitions=transitions, initial="idling", on_final="claim_success")
self.speed = speed
def offender_is_faster(self, offender_speed):
return self.speed < offender_speed
def claim_success(self, **kwargs):
print("The kitten is safe.")
hero = FinalSuperhero(speed=10) # we are not in shape today
hero.called()
assert hero.is_rescuing_kitten()
hero.intervene(offender_speed=15)
# >>> 'The kitten is safe'
assert hero.machine.get_state(hero.state).final # it's over
assert hero.is_offender_gone() # maybe next time ...
Checking state
You can always check the current state of the model by either:
- inspecting the
.state
attribute, or - calling
is_«state name»()
And if you want to retrieve the actual State
object for the current state, you can do that through the Machine
instance's get_state()
method.
lump.state
>>> 'solid'
lump.is_gas()
>>> False
lump.is_solid()
>>> True
machine.get_state(lump.state).name
>>> 'solid'
If you'd like you can choose your own state attribute name by passing the model_attribute
argument while initializing the Machine
. This will also change the name of is_«state name»()
to is_«model_attribute»_«state name»()
though. Similarly, auto transitions will be named to_«model_attribute»_«state name»()
instead of to_«state name»()
. This is done to allow multiple machines to work on the same model with individual state attribute names.
lump = Matter()
machine = Machine(lump, states=['solid', 'liquid', 'gas'], model_attribute='matter_state', initial='solid')
lump.matter_state
>>> 'solid'
# with a custom 'model_attribute', states can also be checked like this:
lump.is_matter_state_solid()
>>> True
lump.to_matter_state_gas()
>>> True
Enumerations
So far we have seen how we can give state names and use these names to work with our state machine. If you favour stricter typing and more IDE code completion (or you just can't type 'sesquipedalophobia' any longer because the word scares you) using Enumerations might be what you are looking for:
import enum # Python 2.7 users need to have 'enum34' installed
from transitions import Machine
class States(enum.Enum):
ERROR = 0
RED = 1
YELLOW = 2
GREEN = 3
transitions = [['proceed', States.RED, States.YELLOW],
['proceed', States.YELLOW, States.GREEN],
['error', '*', States.ERROR]]
m = Machine(states=States, transitions=transitions, initial=States.RED)
assert m.is_RED()
assert m.state is States.RED
state = m.get_state(States.RED) # get transitions.State object
print(state.name) # >>> RED
m.proceed()
m.proceed()
assert m.is_GREEN()
m.error()
assert m.state is States.ERROR
You can mix enums and strings if you like (e.g. [States.RED, 'ORANGE', States.YELLOW, States.GREEN]
) but note that internally, transitions
will still handle states by name (enum.Enum.name
).
Thus, it is not possible to have the states 'GREEN'
and States.GREEN
at the same time.
Transitions
Some of the above examples already illustrate the use of transitions in passing, but here we'll explore them in more detail.
As with states, each transition is represented internally as its own object – an instance of class Transition
. The quickest way to initialize a set of transitions is to pass a dictionary, or list of dictionaries, to the Machine
initializer. We already saw this above:
transitions = [
{ 'trigger': 'melt', 'source': 'solid', 'dest': 'liquid' },
{ 'trigger': 'evaporate', 'source': 'liquid', 'dest': 'gas' },
{ 'trigger': 'sublimate', 'source': 'solid', 'dest': 'gas' },
{ 'trigger': 'ionize', 'source': 'gas', 'dest': 'plasma' }
]
machine = Machine(model=Matter(), states=states, transitions=transitions)
Defining transitions in dictionaries has the benefit of clarity, but can be cumbersome. If you're after brevity, you might choose to define transitions using lists. Just make sure that the elements in each list are in the same order as the positional arguments in the Transition
initialization (i.e., trigger
, source
, destination
, etc.).
The following list-of-lists is functionally equivalent to the list-of-dictionaries above:
transitions = [
['melt', 'solid', 'liquid'],
['evaporate', 'liquid', 'gas'],
['sublimate', 'solid', 'gas'],
['ionize', 'gas', 'plasma']
]
Alternatively, you can add transitions to a Machine
after initialization:
machine = Machine(model=lump, states=states, initial='solid')
machine.add_transition('melt', source='solid', dest='liquid')
Triggering a transition
For a transition to be executed, some event needs to trigger it. There are two ways to do this:
-
Using the automatically attached method in the base model:
>>> lump.melt() >>> lump.state 'liquid' >>> lump.evaporate() >>> lump.state 'gas'
Note how you don't have to explicitly define these methods anywhere; the name of each transition is bound to the model passed to the
Machine
initializer (in this case,lump
). This also means that your model should not already contain methods with the same name as event triggers sincetransitions
will only attach convenience methods to your model if the spot is not already taken. If you want to modify that behaviour, have a look at the FAQ. -
Using the
trigger
method, now attached to your model (if it hasn't been there before). This method lets you execute transitions by name in case dynamic triggering is required:>>> lump.trigger('melt') >>> lump.state 'liquid' >>> lump.trigger('evaporate') >>> lump.state 'gas'
Triggering invalid transitions
By default, triggering an invalid transition will raise an exception:
>>> lump.to_gas()
>>> # This won't work because only objects in a solid state can melt
>>> lump.melt()
transitions.core.MachineError: "Can't trigger event melt from state gas!"
This behavior is generally desirable, since it helps alert you to problems in your code. But in some cases, you might want to silently ignore invalid triggers. You can do this by setting ignore_invalid_triggers=True
(either on a state-by-state basis, or globally for all states):
>>> # Globally suppress invalid trigger exceptions
>>> m = Machine(lump, states, initial='solid', ignore_invalid_triggers=True)
>>> # ...or suppress for only one group of states
>>> states = ['new_state1', 'new_state2']
>>> m.add_states(states, ignore_invalid_triggers=True)
>>> # ...or even just for a single state. Here, exceptions will only be suppressed when the current state is A.
>>> states = [State('A', ignore_invalid_triggers=True), 'B', 'C']
>>> m = Machine(lump, states)
>>> # ...this can be inverted as well if just one state should raise an exception
>>> # since the machine's global value is not applied to a previously initialized state.
>>> states = ['A', 'B', State('C')] # the default value for 'ignore_invalid_triggers' is False
>>> m = Machine(lump, states, ignore_invalid_triggers=True)
If you need to know which transitions are valid from a certain state, you can use get_triggers
:
m.get_triggers('solid')
>>> ['melt', 'sublimate']
m.get_triggers('liquid')
>>> ['evaporate']
m.get_triggers('plasma')
>>> []
# you can also query several states at once
m.get_triggers('solid', 'liquid', 'gas', 'plasma')
>>> ['melt', 'evaporate', 'sublimate', 'ionize']
If you have followed this documentation from the beginning, you will notice that get_triggers
actually returns more triggers than the explicitly defined ones shown above, such as to_liquid
and so on.
These are called auto-transitions
and will be introduced in the next section.
Automatic transitions for all states
In addition to any transitions added explicitly, a to_«state»()
method is created automatically whenever a state is added to a Machine
instance. This method transitions to the target state no matter which state the machine is currently in:
lump.to_liquid()
lump.state
>>> 'liquid'
lump.to_solid()
lump.state
>>> 'solid'
If you desire, you can disable this behavior by setting auto_transitions=False
in the Machine
initializer.
Transitioning from multiple states
A given trigger can be attached to multiple transitions, some of which can potentially begin or end in the same state. For example:
machine.add_transition('transmogrify', ['solid', 'liquid', 'gas'], 'plasma')
machine.add_transition('transmogrify', 'plasma', 'solid')
# This next transition will never execute
machine.add_transition('transmogrify', 'plasma', 'gas')
In this case, calling transmogrify()
will set the model's state to 'solid'
if it's currently 'plasma'
, and set it to 'plasma'
otherwise. (Note that only the first matching transition will execute; thus, the transition defined in the last line above won't do anything.)
You can also make a trigger cause a transition from all states to a particular destination by using the '*'
wildcard:
machine.add_transition('to_liquid', '*', 'liquid')
Note that wildcard transitions will only apply to states that exist at the time of the add_transition() call. Calling a wildcard-based transition when the model is in a state added after the transition was defined will elicit an invalid transition message, and will not transition to the target state.
Reflexive transitions from multiple states
A reflexive trigger (trigger that has the same state as source and destination) can easily be added specifying =
as destination.
This is handy if the same reflexive trigger should be added to multiple states.
For example:
machine.add_transition('touch', ['liquid', 'gas', 'plasma'], '=', after='change_shape')
This will add reflexive transitions for all three states with touch()
as trigger and with change_shape
executed after each trigger.
Internal transitions
In contrast to reflexive transitions, internal transitions will never actually leave the state.
This means that transition-related callbacks such as before
or after
will be processed while state-related callbacks exit
or enter
will not.
To define a transition to be internal, set the destination to None
.
machine.add_transition('internal', ['liquid', 'gas'], None, after='change_shape')
Ordered transitions
A common desire is for state transitions to follow a strict linear sequence. For instance, given states ['A', 'B', 'C']
, you might want valid transitions for A
→ B
, B
→ C
, and C
→ A
(but no other pairs).
To facilitate this behavior, Transitions provides an add_ordered_transitions()
method in the Machine
class:
states = ['A', 'B', 'C']
# See the "alternative initialization" section for an explanation of the 1st argument to init
machine = Machine(states=states, initial='A')
machine.add_ordered_transitions()
machine.next_state()
print(machine.state)
>>> 'B'
# We can also define a different order of transitions
machine = Machine(states=states, initial='A')
machine.add_ordered_transitions(['A', 'C', 'B'])
machine.next_state()
print(machine.state)
>>> 'C'
# Conditions can be passed to 'add_ordered_transitions' as well
# If one condition is passed, it will be used for all transitions
machine = Machine(states=states, initial='A')
machine.add_ordered_transitions(conditions='check')
# If a list is passed, it must contain exactly as many elements as the
# machine contains states (A->B, ..., X->A)
machine = Machine(states=states, initial='A')
machine.add_ordered_transitions(conditions=['check_A2B', ..., 'check_X2A'])
# Conditions are always applied starting from the initial state
machine = Machine(states=states, initial='B')
machine.add_ordered_transitions(conditions=['check_B2C', ..., 'check_A2B'])
# With `loop=False`, the transition from the last state to the first state will be omitted (e.g. C->A)
# When you also pass conditions, you need to pass one condition less (len(states)-1)
machine = Machine(states=states, initial='A')
machine.add_ordered_transitions(loop=False)
machine.next_state()
machine.next_state()
machine.next_state() # transitions.core.MachineError: "Can't trigger event next_state from state C!"
Queued transitions
The default behaviour in Transitions is to process events instantly. This means events within an on_enter
method will be processed before callbacks bound to after
are called.
def go_to_C():
global machine
machine.to_C()
def after_advance():
print("I am in state B now!")
def entering_C():
print("I am in state C now!")
states = ['A', 'B', 'C']
machine = Machine(states=states, initial='A')
# we want a message when state transition to B has been completed
machine.add_transition('advance', 'A', 'B', after=after_advance)
# call transition from state B to state C
machine.on_enter_B(go_to_C)
# we also want a message when entering state C
machine.on_enter_C(entering_C)
machine.advance()
>>> 'I am in state C now!'
>>> 'I am in state B now!' # what?
The execution order of this example is
prepare -> before -> on_enter_B -> on_enter_C -> after.
If queued processing is enabled, a transition will be finished before the next transition is triggered:
machine = Machine(states=states, queued=True, initial='A')
...
machine.advance()
>>> 'I am in state B now!'
>>> 'I am in state C now!' # That's better!
This results in
prepare -> before -> on_enter_B -> queue(to_C) -> after -> on_enter_C.
Important note: when processing events in a queue, the trigger call will always return True
, since there is no way to determine at queuing time whether a transition involving queued calls will ultimately complete successfully. This is true even when only a single event is processed.
machine.add_transition('jump', 'A', 'C', conditions='will_fail')
...
# queued=False
machine.jump()
>>> False
# queued=True
machine.jump()
>>> True
When a model is removed from the machine, transitions
will also remove all related events from the queue.
class Model:
def on_enter_B(self):
self.to_C() # add event to queue ...
self.machine.remove_model(self) # aaaand it's gone
Conditional transitions
Sometimes you only want a particular transition to execute if a specific condition occurs. You can do this by passing a method, or list of methods, in the conditions
argument:
# Our Matter class, now with a bunch of methods that return booleans.
class Matter(object):
def is_flammable(self): return False
def is_really_hot(self): return True
machine.add_transition('heat', 'solid', 'gas', conditions='is_flammable')
machine.add_transition('heat', 'solid', 'liquid', conditions=['is_really_hot'])
In the above example, calling heat()
when the model is in state 'solid'
will transition to state 'gas'
if is_flammable
returns True
. Otherwise, it will transition to state 'liquid'
if is_really_hot
returns True
.
For convenience, there's also an 'unless'
argument that behaves exactly like conditions, but inverted:
machine.add_transition('heat', 'solid', 'gas', unless=['is_flammable', 'is_really_hot'])
In this case, the model would transition from solid to gas whenever heat()
fires, provided that both is_flammable()
and is_really_hot()
return False
.
Note that condition-checking methods will passively receive optional arguments and/or data objects passed to triggering methods. For instance, the following call:
lump.heat(temp=74)
# equivalent to lump.trigger('heat', temp=74)
... would pass the temp=74
optional kwarg to the is_flammable()
check (possibly wrapped in an EventData
instance). For more on this, see the Passing data section below.
Check transitions
If you want to make sure a transition is possible before you go ahead with it, you can use the may_<trigger_name>
functions that have been added to your model.
Your model also contains the may_trigger
function to check a trigger by name:
# check if the current temperature is hot enough to trigger a transition
if lump.may_heat():
# if lump.may_trigger("heat"):
lump.heat()
This will execute all prepare
callbacks and evaluate the conditions assigned to the potential transitions.
Transition checks can also be used when a transition's destination is not available (yet):
machine.add_transition('elevate', 'solid', 'spiritual')
assert not lump.may_elevate() # not ready yet :(
assert not lump.may_trigger("elevate") # same result for checks via trigger name
Callbacks
You can attach callbacks to transitions as well as states. Every transition has 'before'
and 'after'
attributes that contain a list of methods to call before and after the transition executes:
class Matter(object):
def make_hissing_noises(self): print("HISSSSSSSSSSSSSSSS")
def disappear(self): print("where'd all the liquid go?")
transitions = [
{ 'trigger': 'melt', 'source': 'solid', 'dest': 'liquid', 'before': 'make_hissing_noises'},
{ 'trigger': 'evaporate', 'source': 'liquid', 'dest': 'gas', 'after': 'disappear' }
]
lump = Matter()
machine = Machine(lump, states, transitions=transitions, initial='solid')
lump.melt()
>>> "HISSSSSSSSSSSSSSSS"
lump.evaporate()
>>> "where'd all the liquid go?"
There is also a 'prepare'
callback that is executed as soon as a transition starts, before any 'conditions'
are checked or other callbacks are executed.
class Matter(object):
heat = False
attempts = 0
def count_attempts(self): self.attempts += 1
def heat_up(self): self.heat = random.random() < 0.25
def stats(self): print('It took you %i attempts to melt the lump!' %self.attempts)
@property
def is_really_hot(self):
return self.heat
states=['solid', 'liquid', 'gas', 'plasma']
transitions = [
{ 'trigger': 'melt', 'source': 'solid', 'dest': 'liquid', 'prepare': ['heat_up', 'count_attempts'], 'conditions': 'is_really_hot', 'after': 'stats'},
]
lump = Matter()
machine = Machine(lump, states, transitions=transitions, initial='solid')
lump.melt()
lump.melt()
lump.melt()
lump.melt()
>>> "It took you 4 attempts to melt the lump!"
Note that prepare
will not be called unless the current state is a valid source for the named transition.
Default actions meant to be executed before or after every transition can be passed to Machine
during initialization with
before_state_change
and after_state_change
respectively:
class Matter(object):
def make_hissing_noises(self): print("HISSSSSSSSSSSSSSSS")
def disappear(self): print("where'd all the liquid go?")
states=['solid', 'liquid', 'gas', 'plasma']
lump = Matter()
m = Machine(lump, states, before_state_change='make_hissing_noises', after_state_change='disappear')
lump.to_gas()
>>> "HISSSSSSSSSSSSSSSS"
>>> "where'd all the liquid go?"
There are also two keywords for callbacks which should be executed independently a) of how many transitions are possible,
b) if any transition succeeds and c) even if an error is raised during the execution of some other callback.
Callbacks passed to Machine
with prepare_event
will be executed once before processing possible transitions
(and their individual prepare
callbacks) takes place.
Callbacks of finalize_event
will be executed regardless of the success of the processed transitions.
Note that if an error occurred it will be attached to event_data
as error
and can be retrieved with send_event=True
.
from transitions import Machine
class Matter(object):
def raise_error(self, event): raise ValueError("Oh no")
def prepare(self, event): print("I am ready!")
def finalize(self, event): print("Result: ", type(event.error), event.error)
states=['solid', 'liquid', 'gas', 'plasma']
lump = Matter()
m = Machine(lump, states, prepare_event='prepare', before_state_change='raise_error',
finalize_event='finalize', send_event=True)
try:
lump.to_gas()
except ValueError:
pass
print(lump.state)
# >>> I am ready!
# >>> Result: <class 'ValueError'> Oh no
# >>> initial
Sometimes things just don't work out as intended and we need to handle exceptions and clean up the mess to keep things going.
We can pass callbacks to on_exception
to do this:
from transitions import Machine
class Matter(object):
def raise_error(self, event): raise ValueError("Oh no")
def handle_error(self, event):
print("Fixing things ...")
del event.error # it did not happen if we cannot see it ...
states=['solid', 'liquid', 'gas', 'plasma']
lump = Matter()
m = Machine(lump, states, before_state_change='raise_error', on_exception='handle_error', send_event=True)
try:
lump.to_gas()
except ValueError:
pass
print(lump.state)
# >>> Fixing things ...
# >>> initial
Callable resolution
As you have probably already realized, the standard way of passing callables to states, conditions and transitions is by name. When processing callbacks and conditions, transitions
will use their name to retrieve the related callable from the model. If the method cannot be retrieved and it contains dots, transitions
will treat the name as a path to a module function and try to import it. Alternatively, you can pass names of properties or attributes. They will be wrapped into functions but cannot receive event data for obvious reasons. You can also pass callables such as (bound) functions directly. As mentioned earlier, you can also pass lists/tuples of callables names to the callback parameters. Callbacks will be executed in the order they were added.
from transitions import Machine
from mod import imported_func
import random
class Model(object):
def a_callback(self):
imported_func()
@property
def a_property(self):
""" Basically a coin toss. """
return random.random() < 0.5
an_attribute = False
model = Model()
machine = Machine(model=model, states=['A'], initial='A')
machine.add_transition('by_name', 'A', 'A', conditions='a_property', after='a_callback')
machine.add_transition('by_reference', 'A', 'A', unless=['a_property', 'an_attribute'], after=model.a_callback)
machine.add_transition('imported', 'A', 'A', after='mod.imported_func')
model.by_name()
model.by_reference()
model.imported()
The callable resolution is done in Machine.resolve_callable
.
This method can be overridden in case more complex callable resolution strategies are required.
Example
class CustomMachine(Machine):
@staticmethod
def resolve_callable(func, event_data):
# manipulate arguments here and return func, or super() if no manipulation is done.
super(CustomMachine, CustomMachine).resolve_callable(func, event_data)
Callback execution order
In summary, there are currently three ways to trigger events. You can call a model's convenience functions like lump.melt()
,
execute triggers by name such as lump.trigger("melt")
or dispatch events on multiple models with machine.dispatch("melt")
(see section about multiple models in alternative initialization patterns).
Callbacks on transitions are then executed in the following order:
Callback | Current State | Comments |
---|---|---|
'machine.prepare_event' |
source |
executed once before individual transitions are processed |
'transition.prepare' |
source |
executed as soon as the transition starts |
'transition.conditions' |
source |
conditions may fail and halt the transition |
'transition.unless' |
source |
conditions may fail and halt the transition |
'machine.before_state_change' |
source |
default callbacks declared on model |
'transition.before' |
source |
|
'state.on_exit' |
source |
callbacks declared on the source state |
<STATE CHANGE> |
||
'state.on_enter' |
destination |
callbacks declared on the destination state |
'transition.after' |
destination |
|
'machine.on_final' |
destination |
callbacks on children will be called first |
'machine.after_state_change' |
destination |
default callbacks declared on model; will also be called after internal transitions |
'machine.on_exception' |
source/destination |
callbacks will be executed when an exception has been raised |
'machine.finalize_event' |
source/destination |
callbacks will be executed even if no transition took place or an exception has been raised |
If any callback raises an exception, the processing of callbacks is not continued. This means that when an error occurs before the transition (in state.on_exit
or earlier), it is halted. In case there is a raise after the transition has been conducted (in state.on_enter
or later), the state change persists and no rollback is happening. Callbacks specified in machine.finalize_event
will always be executed unless the exception is raised by a finalizing callback itself. Note that each callback sequence has to be finished before the next stage is executed. Blocking callbacks will halt the execution order and therefore block the trigger
or dispatch
call itself. If you want callbacks to be executed in parallel, you could have a look at the extensions AsyncMachine
for asynchronous processing or LockedMachine
for threading.
Passing data
Sometimes you need to pass the callback functions registered at machine initialization some data that reflects the model's current state. Transitions allows you to do this in two different ways.
First (the default), you can pass any positional or keyword arguments directly to the trigger methods (created when you call add_transition()
):
class Matter(object):
def __init__(self): self.set_environment()
def set_environment(self, temp=0, pressure=101.325):
self.temp = temp
self.pressure = pressure
def print_temperature(self): print("Current temperature is %d degrees celsius." % self.temp)
def print_pressure(self): print("Current pressure is %.2f kPa." % self.pressure)
lump = Matter()
machine = Machine(lump, ['solid', 'liquid'], initial='solid')
machine.add_transition('melt', 'solid', 'liquid', before='set_environment')
lump.melt(45) # positional arg;
# equivalent to lump.trigger('melt', 45)
lump.print_temperature()
>>> 'Current temperature is 45 degrees celsius.'
machine.set_state('solid') # reset state so we can melt again
lump.melt(pressure=300.23) # keyword args also work
lump.print_pressure()
>>> 'Current pressure is 300.23 kPa.'
You can pass any number of arguments you like to the trigger.
There is one important limitation to this approach: every callback function triggered by the state transition must be able to handle all of the arguments. This may cause problems if the callbacks each expect somewhat different data.
To get around this, Transitions supports an alternate method for sending data. If you set send_event=True
at Machine
initialization, all arguments to the triggers will be wrapped in an EventData
instance and passed on to every callback. (The EventData
object also maintains internal references to the source state, model, transition, machine, and trigger associated with the event, in case you need to access these for anything.)
class Matter(object):
def __init__(self):
self.temp = 0
self.pressure = 101.325
# Note that the sole argument is now the EventData instance.
# This object stores positional arguments passed to the trigger method in the
# .args property, and stores keywords arguments in the .kwargs dictionary.
def set_environment(self, event):
self.temp = event.kwargs.get('temp', 0)
self.pressure = event.kwargs.get('pressure', 101.325)
def print_pressure(self): print("Current pressure is %.2f kPa." % self.pressure)
lump = Matter()
machine = Machine(lump, ['solid', 'liquid'], send_event=True, initial='solid')
machine.add_transition('melt', 'solid', 'liquid', before='set_environment')
lump.melt(temp=45, pressure=1853.68) # keyword args
lump.print_pressure()
>>> 'Current pressure is 1853.68 kPa.'
Alternative initialization patterns
In all of the examples so far, we've attached a new Machine
instance to a separate model (lump
, an instance of class Matter
). While this separation keeps things tidy (because you don't have to monkey patch a whole bunch of new methods into the Matter
class), it can also get annoying, since it requires you to keep track of which methods are called on the state machine, and which ones are called on the model that the state machine is bound to (e.g., lump.on_enter_StateA()
vs. machine.add_transition()
).
Fortunately, Transitions is flexible, and supports two other initialization patterns.
First, you can create a standalone state machine that doesn't require another model at all. Simply omit the model argument during initialization:
machine = Machine(states=states, transitions=transitions, initial='solid')
machine.melt()
machine.state
>>> 'liquid'
If you initialize the machine this way, you can then attach all triggering events (like evaporate()
, sublimate()
, etc.) and all callback functions directly to the Machine
instance.
This approach has the benefit of consolidating all of the state machine functionality in one place, but can feel a little bit unnatural if you think state logic should be contained within the model itself rather than in a separate controller.
An alternative (potentially better) approach is to have the model inherit from the Machine
class. Transitions is designed to support inheritance seamlessly. (just be sure to override class Machine
's __init__
method!):
class Matter(Machine):
def say_hello(self): print("hello, new state!")
def say_goodbye(self): print("goodbye, old state!")
def __init__(self):
states = ['solid', 'liquid', 'gas']
Machine.__init__(self, states=states, initial='solid')
self.add_transition('melt', 'solid', 'liquid')
lump = Matter()
lump.state
>>> 'solid'
lump.melt()
lump.state
>>> 'liquid'
Here you get to consolidate all state machine functionality into your existing model, which often feels more natural than sticking all of the functionality we want in a separate standalone Machine
instance.
A machine can handle multiple models which can be passed as a list like Machine(model=[model1, model2, ...])
.
In cases where you want to add models as well as the machine instance itself, you can pass the class variable placeholder (string) Machine.self_literal
during initialization like Machine(model=[Machine.self_literal, model1, ...])
.
You can also create a standalone machine, and register models dynamically via machine.add_model
by passing model=None
to the constructor.
Furthermore, you can use machine.dispatch
to trigger events on all currently added models.
Remember to call machine.remove_model
if machine is long-lasting and your models are temporary and should be garbage collected:
class Matter():
pass
lump1 = Matter()
lump2 = Matter()
# setting 'model' to None or passing an empty list will initialize the machine without a model
machine = Machine(model=None, states=states, transitions=transitions, initial='solid')
machine.add_model(lump1)
machine.add_model(lump2, initial='liquid')
lump1.state
>>> 'solid'
lump2.state
>>> 'liquid'
# custom events as well as auto transitions can be dispatched to all models
machine.dispatch("to_plasma")
lump1.state
>>> 'plasma'
assert lump1.state == lump2.state
machine.remove_model([lump1, lump2])
del lump1 # lump1 is garbage collected
del lump2 # lump2 is garbage collected
If you don't provide an initial state in the state machine constructor, transitions
will create and add a default state called 'initial'
.
If you do not want a default initial state, you can pass initial=None
.
However, in this case you need to pass an initial state every time you add a model.
machine = Machine(model=None, states=states, transitions=transitions, initial=None)
machine.add_model(Matter())
>>> "MachineError: No initial state configured for machine, must specify when adding model."
machine.add_model(Matter(), initial='liquid')
Models with multiple states could attach multiple machines using different model_attribute
values. As mentioned in Checking state, this will add custom is/to_<model_attribute>_<state_name>
functions:
lump = Matter()
matter_machine = Machine(lump, states=['solid', 'liquid', 'gas'], initial='solid')
# add a second machine to the same model but assign a different state attribute
shipment_machine = Machine(lump, states=['delivered', 'shipping'], initial='delivered', model_attribute='shipping_state')
lump.state
>>> 'solid'
lump.is_solid() # check the default field
>>> True
lump.shipping_state
>>> 'delivered'
lump.is_shipping_state_delivered() # check the custom field.
>>> True
lump.to_shipping_state_shipping()
>>> True
lump.is_shipping_state_delivered()
>>> False
Logging
Transitions includes very rudimentary logging capabilities. A number of events – namely, state changes, transition triggers, and conditional checks – are logged as INFO-level events using the standard Python logging
module. This means you can easily configure logging to standard output in a script:
# Set up logging; The basic log level will be DEBUG
import logging
logging.basicConfig(level=logging.DEBUG)
# Set transitions' log level to INFO; DEBUG messages will be omitted
logging.getLogger('transitions').setLevel(logging.INFO)
# Business as usual
machine = Machine(states=states, transitions=transitions, initial='solid')
...
(Re-)Storing machine instances
Machines are picklable and can be stored and loaded with pickle
. For Python 3.3 and earlier dill
is required.
import dill as pickle # only required for Python 3.3 and earlier
m = Machine(states=['A', 'B', 'C'], initial='A')
m.to_B()
m.state
>>> B
# store the machine
dump = pickle.dumps(m)
# load the Machine instance again
m2 = pickle.loads(dump)
m2.state
>>> B
m2.states.keys()
>>> ['A', 'B', 'C']
Typing support
As you probably noticed, transitions
uses some of Python's dynamic features to give you handy ways to handle models. However, static type checkers don't like model attributes and methods not being known before runtime. Historically, transitions
also didn't assign convenience methods already defined on models to prevent accidental overrides.
But don't worry! You can use the machine constructor parameter model_override
to change how models are decorated. If you set model_override=True
, transitions
will only override already defined methods. This prevents new methods from showing up at runtime and also allows you to define which helper methods you want to use.
from transitions import Machine
# Dynamic assignment
class Model:
pass
model = Model()
default_machine = Machine(model, states=["A", "B"], transitions=[["go", "A", "B"]], initial="A")
print(model.__dict__.keys()) # all convenience functions have been assigned
# >> dict_keys(['trigger', 'to_A', 'may_to_A', 'to_B', 'may_to_B', 'go', 'may_go', 'is_A', 'is_B', 'state'])
assert model.is_A() # Unresolved attribute reference 'is_A' for class 'Model'
# Predefined assigment: We are just interested in calling our 'go' event and will trigger the other events by name
class PredefinedModel:
# state (or another parameter if you set 'model_attribute') will be assigned anyway
# because we need to keep track of the model's state
state: str
def go(self) -> bool:
raise RuntimeError("Should be overridden!")
def trigger(self, trigger_name: str) -> bool:
raise RuntimeError("Should be overridden!")
model = PredefinedModel()
override_machine = Machine(model, states=["A", "B"], transitions=[["go", "A", "B"]], initial="A", model_override=True)
print(model.__dict__.keys())
# >> dict_keys(['trigger', 'go', 'state'])
model.trigger("to_B")
assert model.state == "B"
If you want to use all the convenience functions and throw some callbacks into the mix, defining a model can get pretty complicated when you have a lot of states and transitions defined.
The method generate_base_model
in transitions
can generate a base model from a machine configuration to help you out with that.
from transitions.experimental.utils import generate_base_model
simple_config = {
"states": ["A", "B"],
"transitions": [
["go", "A", "B"],
],
"initial": "A",
"before_state_change": "call_this",
"model_override": True,
}
class_definition = generate_base_model(simple_config)
with open("base_model.py", "w") as f:
f.write(class_definition)
# ... in another file
from transitions import Machine
from base_model import BaseModel
class Model(BaseModel): # call_this will be an abstract method in BaseModel
def call_this(self) -> None:
# do something
model = Model()
machine = Machine(model, **simple_config)
Defining model methods that will be overridden adds a bit of extra work.
It might be cumbersome to switch back and forth to make sure event names are spelled correctly, especially if states and transitions are defined in lists before or after your model. You can cut down on the boilerplate and the uncertainty of working with strings by defining states as enums. You can also define transitions right in your model class with the help of add_transitions
and event
.
It's up to you whether you use the function decorator add_transitions
or event to assign values to attributes depends on your preferred code style.
They both work the same way, have the same signature, and should result in (almost) the same IDE type hints.
As this is still a work in progress, you'll need to create a custom Machine class and use with_model_definitions for transitions to check for transitions defined that way.
from enum import Enum
from transitions.experimental.utils import with_model_definitions, event, add_transitions, transition
from transitions import Machine
class State(Enum):
A = "A"
B = "B"
C = "C"
class Model:
state: State = State.A
@add_transitions(transition(source=State.A, dest=State.B), [State.C, State.A])
@add_transitions({"source": State.B, "dest": State.A})
def foo(self): ...
bar = event(
{"source": State.B, "dest": State.A, "conditions": lambda: False},
transition(source=State.B, dest=State.C)
)
@with_model_definitions # don't forget to define your model with this decorator!
class MyMachine(Machine):
pass
model = Model()
machine = MyMachine(model, states=State, initial=model.state)
model.foo()
model.bar()
assert model.state == State.C
model.foo()
assert model.state == State.A
Extensions
Even though the core of transitions is kept lightweight, there are a variety of MixIns to extend its functionality. Currently supported are:
- Hierarchical State Machines for nesting and reuse
- Diagrams to visualize the current state of a machine
- Threadsafe Locks for parallel execution
- Async callbacks for asynchronous execution
- Custom States for extended state-related behaviour
There are two mechanisms to retrieve a state machine instance with the desired features enabled.
The first approach makes use of the convenience factory
with the four parameters graph
, nested
, locked
or asyncio
set to True
if the feature is required:
from transitions.extensions import MachineFactory
# create a machine with mixins
diagram_cls = MachineFactory.get_predefined(graph=True)
nested_locked_cls = MachineFactory.get_predefined(nested=True, locked=True)
async_machine_cls = MachineFactory.get_predefined(asyncio=True)
# create instances from these classes
# instances can be used like simple machines
machine1 = diagram_cls(model, state, transitions)
machine2 = nested_locked_cls(model, state, transitions)
This approach targets experimental use since in this case the underlying classes do not have to be known.
However, classes can also be directly imported from transitions.extensions
. The naming scheme is as follows:
Diagrams | Nested | Locked | Asyncio | |
---|---|---|---|---|
Machine | ✘ | ✘ | ✘ | ✘ |
GraphMachine | ✓ | ✘ | ✘ | ✘ |
HierarchicalMachine | ✘ | ✓ | ✘ | ✘ |
LockedMachine | ✘ | ✘ | ✓ | ✘ |
HierarchicalGraphMachine | ✓ | ✓ | ✘ | ✘ |
LockedGraphMachine | ✓ | ✘ | ✓ | ✘ |
LockedHierarchicalMachine | ✘ | ✓ | ✓ | ✘ |
LockedHierarchicalGraphMachine | ✓ | ✓ | ✓ | ✘ |
AsyncMachine | ✘ | ✘ | ✘ | ✓ |
AsyncGraphMachine | ✓ | ✘ | ✘ | ✓ |
HierarchicalAsyncMachine | ✘ | ✓ | ✘ | ✓ |
HierarchicalAsyncGraphMachine | ✓ | ✓ | ✘ | ✓ |
To use a feature-rich state machine, one could write:
from transitions.extensions import LockedHierarchicalGraphMachine as LHGMachine
machine = LHGMachine(model, states, transitions)
Hierarchical State Machine (HSM)
Transitions includes an extension module which allows nesting states.
This allows us to create contexts and to model cases where states are related to certain subtasks in the state machine.
To create a nested state, either import NestedState
from transitions or use a dictionary with the initialization arguments name
and children
.
Optionally, initial
can be used to define a sub state to transit to, when the nested state is entered.
from transitions.extensions import HierarchicalMachine
states = ['standing', 'walking', {'name': 'caffeinated', 'children':['dithering', 'running']}]
transitions = [
['walk', 'standing', 'walking'],
['stop', 'walking', 'standing'],
['drink', '*', 'caffeinated'],
['walk', ['caffeinated', 'caffeinated_dithering'], 'caffeinated_running'],
['relax', 'caffeinated', 'standing']
]
machine = HierarchicalMachine(states=states, transitions=transitions, initial='standing', ignore_invalid_triggers=True)
machine.walk() # Walking now
machine.stop() # let's stop for a moment
machine.drink() # coffee time
machine.state
>>> 'caffeinated'
machine.walk() # we have to go faster
machine.state
>>> 'caffeinated_running'
machine.stop() # can't stop moving!
machine.state
>>> 'caffeinated_running'
machine.relax() # leave nested state
machine.state # phew, what a ride
>>> 'standing'
# machine.on_enter_caffeinated_running('callback_method')
A configuration making use of initial
could look like this:
# ...
states = ['standing', 'walking', {'name': 'caffeinated', 'initial': 'dithering', 'children': ['dithering', 'running']}]
transitions = [
['walk', 'standing', 'walking'],
['stop', 'walking', 'standing'],
# this transition will end in 'caffeinated_dithering'...
['drink', '*', 'caffeinated'],
# ... that is why we do not need do specify 'caffeinated' here anymore
['walk', 'caffeinated_dithering', 'caffeinated_running'],
['relax', 'caffeinated', 'standing']
]
# ...
The initial
keyword of the HierarchicalMachine
constructor accepts nested states (e.g. initial='caffeinated_running'
) and a list of states which is considered to be a parallel state (e.g. initial=['A', 'B']
) or the current state of another model (initial=model.state
) which should be effectively one of the previous mentioned options. Note that when passing a string, transition
will check the targeted state for initial
substates and use this as an entry state. This will be done recursively until a substate does not mention an initial state. Parallel states or a state passed as a list will be used 'as is' and no further initial evaluation will be conducted.
Note that your previously created state object must be a NestedState
or a derived class of it.
The standard State
class used in simple Machine
instances lacks features required for nesting.
from transitions.extensions.nesting import HierarchicalMachine, NestedState
from transitions import State
m = HierarchicalMachine(states=['A'], initial='initial')
m.add_state('B') # fine
m.add_state({'name': 'C'}) # also fine
m.add_state(NestedState('D')) # fine as well
m.add_state(State('E')) # does not work!
Some things that have to be considered when working with nested states: State names are concatenated with NestedState.separator
.
Currently the separator is set to underscore ('_') and therefore behaves similar to the basic machine.
This means a substate bar
from state foo
will be known by foo_bar
. A substate baz
of bar
will be referred to as foo_bar_baz
and so on.
When entering a substate, enter
will be called for all parent states. The same is true for exiting substates.
Third, nested states can overwrite transition behaviour of their parents.
If a transition is not known to the current state it will be delegated to its parent.
This means that in the standard configuration, state names in HSMs MUST NOT contain underscores.
For transitions
it's impossible to tell whether machine.add_state('state_name')
should add a state named state_name
or add a substate name
to the state state
.
In some cases this is not sufficient however.
For instance if state names consist of more than one word and you want/need to use underscore to separate them instead of CamelCase
.
To deal with this, you can change the character used for separation quite easily.
You can even use fancy unicode characters if you use Python 3.
Setting the separator to something else than underscore changes some of the behaviour (auto_transition and setting callbacks) though:
from transitions.extensions import HierarchicalMachine
from transitions.extensions.nesting import NestedState
NestedState.separator = '↦'
states = ['A', 'B',
{'name': 'C', 'children':['1', '2',
{'name': '3', 'children': ['a', 'b', 'c']}
]}
]
transitions = [
['reset', 'C', 'A'],
['reset', 'C↦2', 'C'] # overwriting parent reset
]
# we rely on auto transitions
machine = HierarchicalMachine(states=states, transitions=transitions, initial='A')
machine.to_B() # exit state A, enter state B
machine.to_C() # exit B, enter C
machine.to_C.s3.a() # enter C↦a; enter C↦3↦a;
machine.state
>>> 'C↦3↦a'
assert machine.is_C.s3.a()
machine.to('C↦2') # not interactive; exit C↦3↦a, exit C↦3, enter C↦2
machine.reset() # exit C↦2; reset C has been overwritten by C↦3
machine.state
>>> 'C'
machine.reset() # exit C, enter A
machine.state
>>> 'A'
# s.on_enter('C↦3↦a', 'callback_method')
Instead of to_C_3_a()
auto transition is called as to_C.s3.a()
. If your substate starts with a digit, transitions adds a prefix 's' ('3' becomes 's3') to the auto transition FunctionWrapper
to comply with the attribute naming scheme of Python.
If interactive completion is not required, to('C↦3↦a')
can be called directly. Additionally, on_enter/exit_<<state name>>
is replaced with on_enter/exit(state_name, callback)
. State checks can be conducted in a similar fashion. Instead of is_C_3_a()
, the FunctionWrapper
variant is_C.s3.a()
can be used.
To check whether the current state is a substate of a specific state, is_state
supports the keyword allow_substates
:
machine.state
>>> 'C.2.a'
machine.is_C() # checks for specific states
>>> False
machine.is_C(allow_substates=True)
>>> True
assert machine.is_C.s2() is False
assert machine.is_C.s2(allow_substates=True) # FunctionWrapper support allow_substate as well
You can use enumerations in HSMs as well but keep in mind that Enum
are compared by value.
If you have a value more than once in a state tree those states cannot be distinguished.
states = [States.RED, States.YELLOW, {'name': States.GREEN, 'children': ['tick', 'tock']}]
states = ['A', {'name': 'B', 'children': states, 'initial': States.GREEN}, States.GREEN]
machine = HierarchicalMachine(states=states)
machine.to_B()
machine.is_GREEN() # returns True even though the actual state is B_GREEN
HierarchicalMachine
has been rewritten from scratch to support parallel states and better isolation of nested states.
This involves some tweaks based on community feedback.
To get an idea of processing order and configuration have a look at the following example:
from transitions.extensions.nesting import HierarchicalMachine
import logging
states = ['A', 'B', {'name': 'C', 'parallel': [{'name': '1', 'children': ['a', 'b', 'c'], 'initial': 'a',
'transitions': [['go', 'a', 'b']]},
{'name': '2', 'children': ['x', 'y', 'z'], 'initial': 'z'}],
'transitions': [['go', '2_z', '2_x']]}]
transitions = [['reset', 'C_1_b', 'B']]
logging.basicConfig(level=logging.INFO)
machine = HierarchicalMachine(states=states, transitions=transitions, initial='A')
machine.to_C()
# INFO:transitions.extensions.nesting:Exited state A
# INFO:transitions.extensions.nesting:Entered state C
# INFO:transitions.extensions.nesting:Entered state C_1
# INFO:transitions.extensions.nesting:Entered state C_2
# INFO:transitions.extensions.nesting:Entered state C_1_a
# INFO:transitions.extensions.nesting:Entered state C_2_z
machine.go()
# INFO:transitions.extensions.nesting:Exited state C_1_a
# INFO:transitions.extensions.nesting:Entered state C_1_b
# INFO:transitions.extensions.nesting:Exited state C_2_z
# INFO:transitions.extensions.nesting:Entered state C_2_x
machine.reset()
# INFO:transitions.extensions.nesting:Exited state C_1_b
# INFO:transitions.extensions.nesting:Exited state C_2_x
# INFO:transitions.extensions.nesting:Exited state C_1
# INFO:transitions.extensions.nesting:Exited state C_2
# INFO:transitions.extensions.nesting:Exited state C
# INFO:transitions.extensions.nesting:Entered state B
When using parallel
instead of children
, transitions
will enter all states of the passed list at the same time.
Which substate to enter is defined by initial
which should always point to a direct substate.
A novel feature is to define local transitions by passing the transitions
keyword in a state definition.
The above defined transition ['go', 'a', 'b']
is only valid in C_1
.
While you can reference substates as done in ['go', '2_z', '2_x']
you cannot reference parent states directly in locally defined transitions.
When a parent state is exited, its children will also be exited.
In addition to the processing order of transitions known from Machine
where transitions are considered in the order they were added, HierarchicalMachine
considers hierarchy as well.
Transitions defined in substates will be evaluated first (e.g. C_1_a
is left before C_2_z
) and transitions defined with wildcard *
will (for now) only add transitions to root states (in this example A
, B
, C
)
Starting with 0.8.0 nested states can be added directly and will issue the creation of parent states on-the-fly:
m = HierarchicalMachine(states=['A'], initial='A')
m.add_state('B_1_a')
m.to_B_1()
assert m.is_B(allow_substates=True)
Experimental in 0.9.1:
You can make use of on_final
callbacks either in states or on the HSM itself. Callbacks will be triggered if a) the state itself is tagged with final
and has just been entered or b) all substates are considered final and at least one substate just entered a final state. In case of b) all parents will be considered final as well if condition b) holds true for them. This might be useful in cases where processing happens in parallel and your HSM or any parent state should be notified when all substates have reached a final state:
from transitions.extensions import HierarchicalMachine
from functools import partial
# We initialize this parallel HSM in state A:
# / X
# / / yI
# A -> B - Y - yII [final]
# \ Z - zI
# \ zII [final]
def final_event_raised(name):
print("{} is final!".format(name))
states = ['A', {'name': 'B', 'parallel': [{'name': 'X', 'final': True, 'on_final': partial(final_event_raised, 'X')},
{'name': 'Y', 'transitions': [['final_Y', 'yI', 'yII']],
'initial': 'yI',
'on_final': partial(final_event_raised, 'Y'),
'states':
['yI', {'name': 'yII', 'final': True}]
},
{'name': 'Z', 'transitions': [['final_Z', 'zI', 'zII']],
'initial': 'zI',
'on_final': partial(final_event_raised, 'Z'),
'states':
['zI', {'name': 'zII', 'final': True}]
},
],
"on_final": partial(final_event_raised, 'B')}]
machine = HierarchicalMachine(states=states, on_final=partial(final_event_raised, 'Machine'), initial='A')
# X will emit a final event right away
machine.to_B()
# >>> X is final!
print(machine.state)
# >>> ['B_X', 'B_Y_yI', 'B_Z_zI']
# Y's substate is final now and will trigger 'on_final' on Y
machine.final_Y()
# >>> Y is final!
print(machine.state)
# >>> ['B_X', 'B_Y_yII', 'B_Z_zI']
# Z's substate becomes final which also makes all children of B final and thus machine itself
machine.final_Z()
# >>> Z is final!
# >>> B is final!
# >>> Machine is final!
Reuse of previously created HSMs
Besides semantic order, nested states are very handy if you want to specify state machines for specific tasks and plan to reuse them.
Before 0.8.0, a HierarchicalMachine
would not integrate the machine instance itself but the states and transitions by creating copies of them.
However, since 0.8.0 (Nested)State
instances are just referenced which means changes in one machine's collection of states and events will influence the other machine instance. Models and their state will not be shared though.
Note that events and transitions are also copied by reference and will be shared by both instances if you do not use the remap
keyword.
This change was done to be more in line with Machine
which also uses passed State
instances by reference.
count_states = ['1', '2', '3', 'done']
count_trans = [
['increase', '1', '2'],
['increase', '2', '3'],
['decrease', '3', '2'],
['decrease', '2', '1'],
['done', '3', 'done'],
['reset', '*', '1']
]
counter = HierarchicalMachine(states=count_states, transitions=count_trans, initial='1')
counter.increase() # love my counter
states = ['waiting', 'collecting', {'name': 'counting', 'children': counter}]
transitions = [
['collect', '*', 'collecting'],
['wait', '*', 'waiting'],
['count', 'collecting', 'counting']
]
collector = HierarchicalMachine(states=states, transitions=transitions, initial='waiting')
collector.collect() # collecting
collector.count() # let's see what we got; counting_1
collector.increase() # counting_2
collector.increase() # counting_3
collector.done() # collector.state == counting_done
collector.wait() # collector.state == waiting
If a HierarchicalMachine
is passed with the children
keyword, the initial state of this machine will be assigned to the new parent state.
In the above example we see that entering counting
will also enter counting_1
.
If this is undesired behaviour and the machine should rather halt in the parent state, the user can pass initial
as False
like {'name': 'counting', 'children': counter, 'initial': False}
.
Sometimes you want such an embedded state collection to 'return' which means after it is done it should exit and transit to one of your super states.
To achieve this behaviour you can remap state transitions.
In the example above we would like the counter to return if the state done
was reached.
This is done as follows:
states = ['waiting', 'collecting', {'name': 'counting', 'children': counter, 'remap': {'done': 'waiting'}}]
... # same as above
collector.increase() # counting_3
collector.done()
collector.state
>>> 'waiting' # be aware that 'counting_done' will be removed from the state machine
As mentioned above, using remap
will copy events and transitions since they could not be valid in the original state machine.
If a reused state machine does not have a final state, you can of course add the transitions manually.
If 'counter' had no 'done' state, we could just add ['done', 'counter_3', 'waiting']
to achieve the same behaviour.
In cases where you want states and transitions to be copied by value rather than reference (for instance, if you want to keep the pre-0.8 behaviour) you can do so by creating a NestedState
and assigning deep copies of the machine's events and states to it.
from transitions.extensions.nesting import NestedState
from copy import deepcopy
# ... configuring and creating counter
counting_state = NestedState(name="counting", initial='1')
counting_state.states = deepcopy(counter.states)
counting_state.events = deepcopy(counter.events)
states = ['waiting', 'collecting', counting_state]
For complex state machines, sharing configurations rather than instantiated machines might be more feasible.
Especially since instantiated machines must be derived from HierarchicalMachine
.
Such configurations can be stored and loaded easily via JSON or YAML (see the FAQ).
HierarchicalMachine
allows defining substates either with the keyword children
or states
.
If both are present, only children
will be considered.
counter_conf = {
'name': 'counting',
'states': ['1', '2', '3', 'done'],
'transitions': [
['increase', '1', '2'],
['increase', '2', '3'],
['decrease', '3', '2'],
['decrease', '2', '1'],
['done', '3', 'done'],
['reset', '*', '1']
],
'initial': '1'
}
collector_conf = {
'name': 'collector',
'states': ['waiting', 'collecting', counter_conf],
'transitions': [
['collect', '*', 'collecting'],
['wait', '*', 'waiting'],
['count', 'collecting', 'counting']
],
'initial': 'waiting'
}
collector = HierarchicalMachine(**collector_conf)
collector.collect()
collector.count()
collector.increase()
assert collector.is_counting_2()
Diagrams
Additional Keywords:
title
(optional): Sets the title of the generated image.show_conditions
(default False): Shows conditions at transition edgesshow_auto_transitions
(default False): Shows auto transitions in graphshow_state_attributes
(default False): Show callbacks (enter, exit), tags and timeouts in graph
Transitions can generate basic state diagrams displaying all valid transitions between states. The basic diagram support generates a mermaid state machine definition which can be used with mermaid's live editor, in markdown files in GitLab or GitHub and other web services. For instance, this code:
from transitions.extensions.diagrams import HierarchicalGraphMachine
import pyperclip
states = ['A', 'B', {'name': 'C',
'final': True,
'parallel': [{'name': '1', 'children': ['a', {"name": "b", "final": True}],
'initial': 'a',
'transitions': [['go', 'a', 'b']]},
{'name': '2', 'children': ['a', {"name": "b", "final": True}],
'initial': 'a',
'transitions': [['go', 'a', 'b']]}]}]
transitions = [['reset', 'C', 'A'], ["init", "A", "B"], ["do", "B", "C"]]
m = HierarchicalGraphMachine(states=states, transitions=transitions, initial="A", show_conditions=True,
title="Mermaid", graph_engine="mermaid", auto_transitions=False)
m.init()
pyperclip.copy(m.get_graph().draw(None)) # using pyperclip for convenience
print("Graph copied to clipboard!")
Produces this diagram (check the document source to see the markdown notation):
---
Mermaid Graph
---
stateDiagram-v2
direction LR
classDef s_default fill:white,color:black
classDef s_inactive fill:white,color:black
classDef s_parallel color:black,fill:white
classDef s_active color:red,fill:darksalmon
classDef s_previous color:blue,fill:azure
state "A" as A
Class A s_previous
state "B" as B
Class B s_active
state "C" as C
C --> [*]
Class C s_default
state C {
state "1" as C_1
state C_1 {
[*] --> C_1_a
state "a" as C_1_a
state "b" as C_1_b
C_1_b --> [*]
}
--
state "2" as C_2
state C_2 {
[*] --> C_2_a
state "a" as C_2_a
state "b" as C_2_b
C_2_b --> [*]
}
}
C --> A: reset
A --> B: init
B --> C: do
C_1_a --> C_1_b: go
C_2_a --> C_2_b: go
[*] --> A
To use more sophisticated graphing functionality, you'll need to have graphviz
and/or pygraphviz
installed.
To generate graphs with the package graphviz
, you need to install Graphviz manually or via a package manager.
sudo apt-get install graphviz graphviz-dev # Ubuntu and Debian
brew install graphviz # MacOS
conda install graphviz python-graphviz # (Ana)conda
Now you can install the actual Python packages
pip install graphviz pygraphviz # install graphviz and/or pygraphviz manually...
pip install transitions[diagrams] # ... or install transitions with 'diagrams' extras which currently depends on pygraphviz
Currently, GraphMachine
will use pygraphviz
when available and fall back to graphviz
when pygraphviz
cannot be
found.
If graphviz
is not available either, mermaid
will be used.
This can be overridden by passing graph_engine="graphviz"
(or "mermaid"
) to the constructor.
Note that this default might change in the future and pygraphviz
support may be dropped.
With Model.get_graph()
you can get the current graph or the region of interest (roi) and draw it like this:
# import transitions
from transitions.extensions import GraphMachine
m = Model()
# without further arguments pygraphviz will be used
machine = GraphMachine(model=m, ...)
# when you want to use graphviz explicitly
machine = GraphMachine(model=m, graph_engine="graphviz", ...)
# in cases where auto transitions should be visible
machine = GraphMachine(model=m, show_auto_transitions=True, ...)
# draw the whole graph ...
m.get_graph().draw('my_state_diagram.png', prog='dot')
# ... or just the region of interest
# (previous state, active state and all reachable states)
roi = m.get_graph(show_roi=True).draw('my_state_diagram.png', prog='dot')
This produces something like this:
Independent of the backend you use, the draw function also accepts a file descriptor or a binary stream as the first argument. If you set this parameter to None
, the byte stream will be returned:
import io
with open('a_graph.png', 'bw') as f:
# you need to pass the format when you pass objects instead of filenames.
m.get_graph().draw(f, format="png", prog='dot')
# you can pass a (binary) stream too
b = io.BytesIO()
m.get_graph().draw(b, format="png", prog='dot')
# or just handle the binary string yourself
result = m.get_graph().draw(None, format="png", prog='dot')
assert result == b.getvalue()
References and partials passed as callbacks will be resolved as good as possible:
from transitions.extensions import GraphMachine
from functools import partial
class Model:
def clear_state(self, deep=False, force=False):
print("Clearing state ...")
return True
model = Model()
machine = GraphMachine(model=model, states=['A', 'B', 'C'],
transitions=[
{'trigger': 'clear', 'source': 'B', 'dest': 'A', 'conditions': model.clear_state},
{'trigger': 'clear', 'source': 'C', 'dest': 'A',
'conditions': partial(model.clear_state, False, force=True)},
],
initial='A', show_conditions=True)
model.get_graph().draw('my_state_diagram.png', prog='dot')
This should produce something similar to this:
If the format of references does not suit your needs, you can override the static method GraphMachine.format_references
. If you want to skip reference entirely, just let GraphMachine.format_references
return None
.
Also, have a look at our example IPython/Jupyter notebooks for a more detailed example about how to use and edit graphs.
Threadsafe(-ish) State Machine
In cases where event dispatching is done in threads, one can use either LockedMachine
or LockedHierarchicalMachine
where function access (!sic) is secured with reentrant locks.
This does not save you from corrupting your machine by tinkering with member variables of your model or state machine.
from transitions.extensions import LockedMachine
from threading import Thread
import time
states = ['A', 'B', 'C']
machine = LockedMachine(states=states, initial='A')
# let us assume that entering B will take some time
thread = Thread(target=machine.to_B)
thread.start()
time.sleep(0.01) # thread requires some time to start
machine.to_C() # synchronized access; won't execute before thread is done
# accessing attributes directly
thread = Thread(target=machine.to_B)
thread.start()
machine.new_attrib = 42 # not synchronized! will mess with execution order
Any python context manager can be passed in via the machine_context
keyword argument:
from transitions.extensions import LockedMachine
from threading import RLock
states = ['A', 'B', 'C']
lock1 = RLock()
lock2 = RLock()
machine = LockedMachine(states=states, initial='A', machine_context=[lock1, lock2])
Any contexts via machine_model
will be shared between all models registered with the Machine
.
Per-model contexts can be added as well:
lock3 = RLock()
machine.add_model(model, model_context=lock3)
It's important that all user-provided context managers are re-entrant since the state machine will call them multiple times, even in the context of a single trigger invocation.
Using async callbacks
If you are using Python 3.7 or later, you can use AsyncMachine
to work with asynchronous callbacks.
You can mix synchronous and asynchronous callbacks if you like but this may have undesired side effects.
Note that events need to be awaited and the event loop must also be handled by you.
from transitions.extensions.asyncio import AsyncMachine
import asyncio
import time
class AsyncModel:
def prepare_model(self):
print("I am synchronous.")
self.start_time = time.time()
async def before_change(self):
print("I am asynchronous and will block now for 100 milliseconds.")
await asyncio.sleep(0.1)
print("I am done waiting.")
def sync_before_change(self):
print("I am synchronous and will block the event loop (what I probably shouldn't)")
time.sleep(0.1)
print("I am done waiting synchronously.")
def after_change(self):
print(f"I am synchronous again. Execution took {int((time.time() - self.start_time) * 1000)} ms.")
transition = dict(trigger="start", source="Start", dest="Done", prepare="prepare_model",
before=["before_change"] * 5 + ["sync_before_change"],
after="after_change") # execute before function in asynchronously 5 times
model = AsyncModel()
machine = AsyncMachine(model, states=["Start", "Done"], transitions=[transition], initial='Start')
asyncio.get_event_loop().run_until_complete(model.start())
# >>> I am synchronous.
# I am asynchronous and will block now for 100 milliseconds.
# I am asynchronous and will block now for 100 milliseconds.
# I am asynchronous and will block now for 100 milliseconds.
# I am asynchronous and will block now for 100 milliseconds.
# I am asynchronous and will block now for 100 milliseconds.
# I am synchronous and will block the event loop (what I probably shouldn't)
# I am done waiting synchronously.
# I am done waiting.
# I am done waiting.
# I am done waiting.
# I am done waiting.
# I am done waiting.
# I am synchronous again. Execution took 101 ms.
assert model.is_Done()
So, why do you need to use Python 3.7 or later you may ask.
Async support has been introduced earlier.
AsyncMachine
makes use of contextvars
to handle running callbacks when new events arrive before a transition
has been finished:
async def await_never_return():
await asyncio.sleep(100)
raise ValueError("That took too long!")
async def fix():
await m2.fix()
m1 = AsyncMachine(states=['A', 'B', 'C'], initial='A', name="m1")
m2 = AsyncMachine(states=['A', 'B', 'C'], initial='A', name="m2")
m2.add_transition(trigger='go', source='A', dest='B', before=await_never_return)
m2.add_transition(trigger='fix', source='A', dest='C')
m1.add_transition(trigger='go', source='A', dest='B', after='go')
m1.add_transition(trigger='go', source='B', dest='C', after=fix)
asyncio.get_event_loop().run_until_complete(asyncio.gather(m2.go(), m1.go()))
assert m1.state == m2.state
This example actually illustrates two things:
First, that 'go' called in m1's transition from A
to be B
is not cancelled and second, calling m2.fix()
will
halt the transition attempt of m2 from A
to B
by executing 'fix' from A
to C
.
This separation would not be possible without contextvars
.
Note that prepare
and conditions
are NOT treated as ongoing transitions.
This means that after conditions
have been evaluated, a transition is executed even though another event already happened.
Tasks will only be cancelled when run as a before
callback or later.
AsyncMachine
features a model-special queue mode which can be used when queued='model'
is passed to the constructor.
With a model-specific queue, events will only be queued when they belong to the same model.
Furthermore, a raised exception will only clear the event queue of the model that raised that exception.
For the sake of simplicity, let's assume that every event in asyncio.gather
below is not triggered at the same time but slightly delayed:
asyncio.gather(model1.event1(), model1.event2(), model2.event1())
# execution order with AsyncMachine(queued=True)
# model1.event1 -> model1.event2 -> model2.event1
# execution order with AsyncMachine(queued='model')
# (model1.event1, model2.event1) -> model1.event2
asyncio.gather(model1.event1(), model1.error(), model1.event3(), model2.event1(), model2.event2(), model2.event3())
# execution order with AsyncMachine(queued=True)
# model1.event1 -> model1.error
# execution order with AsyncMachine(queued='model')
# (model1.event1, model2.event1) -> (model1.error, model2.event2) -> model2.event3
Note that queue modes must not be changed after machine construction.
Adding features to states
If your superheroes need some custom behaviour, you can throw in some extra functionality by decorating machine states:
from time import sleep
from transitions import Machine
from transitions.extensions.states import add_state_features, Tags, Timeout
@add_state_features(Tags, Timeout)
class CustomStateMachine(Machine):
pass
class SocialSuperhero(object):
def __init__(self):
self.entourage = 0
def on_enter_waiting(self):
self.entourage += 1
states = [{'name': 'preparing', 'tags': ['home', 'busy']},
{'name': 'waiting', 'timeout': 1, 'on_timeout': 'go'},
{'name': 'away'}] # The city needs us!
transitions = [['done', 'preparing', 'waiting'],
['join', 'waiting', 'waiting'], # Entering Waiting again will increase our entourage
['go', 'waiting', 'away']] # Okay, let' move
hero = SocialSuperhero()
machine = CustomStateMachine(model=hero, states=states, transitions=transitions, initial='preparing')
assert hero.state == 'preparing' # Preparing for the night shift
assert machine.get_state(hero.state).is_busy # We are at home and busy
hero.done()
assert hero.state == 'waiting' # Waiting for fellow superheroes to join us
assert hero.entourage == 1 # It's just us so far
sleep(0.7) # Waiting...
hero.join() # Weeh, we got company
sleep(0.5) # Waiting...
hero.join() # Even more company \o/
sleep(2) # Waiting...
assert hero.state == 'away' # Impatient superhero already left the building
assert machine.get_state(hero.state).is_home is False # Yupp, not at home anymore
assert hero.entourage == 3 # At least he is not alone
Currently, transitions comes equipped with the following state features:
-
Timeout -- triggers an event after some time has passed
- keyword:
timeout
(int, optional) -- if passed, an entered state will timeout aftertimeout
seconds - keyword:
on_timeout
(string/callable, optional) -- will be called when timeout time has been reached - will raise an
AttributeError
whentimeout
is set buton_timeout
is not - Note: A timeout is triggered in a thread. This implies several limitations (e.g. catching Exceptions raised in timeouts). Consider an event queue for more sophisticated applications.
- keyword:
-
Tags -- adds tags to states
- keyword:
tags
(list, optional) -- assigns tags to a state State.is_<tag_name>
will returnTrue
when the state has been tagged withtag_name
, elseFalse
- keyword:
-
Error -- raises a
MachineError
when a state cannot be left- inherits from
Tags
(if you useError
do not useTags
) - keyword:
accepted
(bool, optional) -- marks a state as accepted - alternatively the keyword
tags
can be passed, containing 'accepted' - Note: Errors will only be raised if
auto_transitions
has been set toFalse
. Otherwise every state can be exited withto_<state>
methods.
- inherits from
-
Volatile -- initialises an object every time a state is entered
- keyword:
volatile
(class, optional) -- every time the state is entered an object of type class will be assigned to the model. The attribute name is defined byhook
. If omitted, an empty VolatileObject will be created instead - keyword:
hook
(string, default='scope') -- The model's attribute name for the temporal object.
- keyword:
You can write your own State
extensions and add them the same way. Just note that add_state_features
expects Mixins. This means your extension should always call the overridden methods __init__
, enter
and exit
. Your extension may inherit from State but will also work without it.
Using @add_state_features
has a drawback which is that decorated machines cannot be pickled (more precisely, the dynamically generated CustomState
cannot be pickled).
This might be a reason to write a dedicated custom state class instead.
Depending on the chosen state machine, your custom state class may need to provide certain state features. For instance, HierarchicalMachine
requires your custom state to be an instance of NestedState
(State
is not sufficient). To inject your states you can either assign them to your Machine
's class attribute state_cls
or override Machine.create_state
in case you need some specific procedures done whenever a state is created:
from transitions import Machine, State
class MyState(State):
pass
class CustomMachine(Machine):
# Use MyState as state class
state_cls = MyState
class VerboseMachine(Machine):
# `Machine._create_state` is a class method but we can
# override it to be an instance method
def _create_state(self, *args, **kwargs):
print("Creating a new state with machine '{0}'".format(self.name))
return MyState(*args, **kwargs)
If you want to avoid threads in your AsyncMachine
entirely, you can replace the Timeout
state feature with AsyncTimeout
from the asyncio
extension:
import asyncio
from transitions.extensions.states import add_state_features
from transitions.extensions.asyncio import AsyncTimeout, AsyncMachine
@add_state_features(AsyncTimeout)
class TimeoutMachine(AsyncMachine):
pass
states = ['A', {'name': 'B', 'timeout': 0.2, 'on_timeout': 'to_C'}, 'C']
m = TimeoutMachine(states=states, initial='A', queued=True) # see remark below
asyncio.run(asyncio.wait([m.to_B(), asyncio.sleep(0.1)]))
assert m.is_B() # timeout shouldn't be triggered
asyncio.run(asyncio.wait([m.to_B(), asyncio.sleep(0.3)]))
assert m.is_C() # now timeout should have been processed
You should consider passing queued=True
to the TimeoutMachine
constructor. This will make sure that events are processed sequentially and avoid asynchronous racing conditions that may appear when timeout and event happen in proximity.
Using transitions together with Django
You can have a look at the FAQ for some inspiration or checkout django-transitions
.
It has been developed by Christian Ledermann and is also hosted on Github.
The documentation contains some usage examples.
I have a [bug report/issue/question]...
First, congratulations! You reached the end of the documentation!
If you want to try out transitions
before you install it, you can do that in an interactive Jupyter notebook at mybinder.org.
Just click this button 👉 .
For bug reports and other issues, please open an issue on GitHub.
For usage questions, post on Stack Overflow, making sure to tag your question with the pytransitions
tag. Do not forget to have a look at the extended examples!
For any other questions, solicitations, or large unrestricted monetary gifts, email Tal Yarkoni (initial author) and/or Alexander Neumann (current maintainer).
Resourceswhich are currently available to browse on.
mail [email protected] to add your project or resources here 🔥.
- 1dataclasses — Data Classes
https://docs.python.org/3/library/dataclasses.html
Source code: Lib/dataclasses.py This module provides a decorator and functions for automatically adding generated special methods such as__init__() and__repr__() to user-defined classes. It was ori...
- 2curses — Terminal handling for character-cell displays
https://docs.python.org/3/library/curses.html
Source code: Lib/curses The curses module provides an interface to the curses library, the de-facto standard for portable advanced terminal handling. While curses is most widely used in the Unix en...
- 3cssutils
https://pypi.org/project/cssutils/
A CSS Cascading Style Sheets library for Python
- 4selenium
https://pypi.org/project/selenium/
Official Python bindings for Selenium WebDriver
- 5Coroutine-based concurrency library for Python
https://github.com/gevent/gevent
Coroutine-based concurrency library for Python. Contribute to gevent/gevent development by creating an account on GitHub.
- 6Django Channels HTTP/WebSocket server
https://github.com/django/daphne
Django Channels HTTP/WebSocket server. Contribute to django/daphne development by creating an account on GitHub.
- 7Command Line Interface Formulation Framework. Mirror of code maintained at opendev.org.
https://github.com/openstack/cliff
Command Line Interface Formulation Framework. Mirror of code maintained at opendev.org. - openstack/cliff
- 8Because sometimes you need to do it live
https://github.com/sloria/doitlive
Because sometimes you need to do it live. Contribute to sloria/doitlive development by creating an account on GitHub.
- 9Python dictionaries with advanced dot notation access
https://github.com/cdgriffith/Box
Python dictionaries with advanced dot notation access - cdgriffith/Box
- 10Simple cross-platform colored terminal text in Python
https://github.com/tartley/colorama
Simple cross-platform colored terminal text in Python - tartley/colorama
- 11asyncio — Asynchronous I/O
https://docs.python.org/3/library/asyncio.html
Hello World!: asyncio is a library to write concurrent code using the async/await syntax. asyncio is used as a foundation for multiple Python asynchronous frameworks that provide high-performance n...
- 12difflib — Helpers for computing deltas
https://docs.python.org/3/library/difflib.html
Source code: Lib/difflib.py This module provides classes and functions for comparing sequences. It can be used for example, for comparing files, and can produce information about file differences i...
- 13Open Source Cloud Computing Infrastructure - OpenStack
https://www.openstack.org/
OpenStack is an open source cloud computing infrastructure software project and is one of the three most active open source projects in the world.
- 14multiprocessing — Process-based parallelism
https://docs.python.org/3/library/multiprocessing.html
Source code: Lib/multiprocessing/ Availability: not Emscripten, not WASI. This module does not work or is not available on WebAssembly platforms wasm32-emscripten and wasm32-wasi. See WebAssembly p...
- 15Hypercorn is an ASGI and WSGI Server based on Hyper libraries and inspired by Gunicorn.
https://github.com/pgjones/hypercorn
Hypercorn is an ASGI and WSGI Server based on Hyper libraries and inspired by Gunicorn. - pgjones/hypercorn
- 16Automatic caching and invalidation for Django models through the ORM.
https://github.com/django-cache-machine/django-cache-machine
Automatic caching and invalidation for Django models through the ORM. - django-cache-machine/django-cache-machine
- 17A jazzy skin for the Django Admin-Interface (official repository).
https://github.com/sehmaschine/django-grappelli
A jazzy skin for the Django Admin-Interface (official repository). - sehmaschine/django-grappelli
- 18A Python wrapper for the tesseract-ocr API
https://github.com/sirfz/tesserocr
A Python wrapper for the tesseract-ocr API. Contribute to sirfz/tesserocr development by creating an account on GitHub.
- 19Library and command-line utility for rendering projects templates.
https://github.com/copier-org/copier
Library and command-line utility for rendering projects templates. - copier-org/copier
- 20Scrapy, a fast high-level web crawling & scraping framework for Python.
https://github.com/scrapy/scrapy
Scrapy, a fast high-level web crawling & scraping framework for Python. - scrapy/scrapy
- 21Python - Visual Studio Marketplace
https://marketplace.visualstudio.com/items?itemName=ms-python.python
Extension for Visual Studio Code - Python language support with extension access points for IntelliSense (Pylance), Debugging (Python Debugger), linting, formatting, refactoring, unit tests, and more.
- 22coverage
https://pypi.org/project/coverage/
Code coverage measurement for Python
- 23Integrated set of Django applications addressing authentication, registration, account management as well as 3rd party (social) account authentication.
https://github.com/pennersr/django-allauth
Integrated set of Django applications addressing authentication, registration, account management as well as 3rd party (social) account authentication. - pennersr/django-allauth
- 24doublex
https://pypi.org/project/doublex/
Python test doubles
- 25configparser — Configuration file parser
https://docs.python.org/3/library/configparser.html
Source code: Lib/configparser.py This module provides the ConfigParser class which implements a basic configuration language which provides a structure similar to what’s found in Microsoft Windows ...
- 26WSGI middleware for sessions and caching
https://github.com/bbangert/beaker
WSGI middleware for sessions and caching. Contribute to bbangert/beaker development by creating an account on GitHub.
- 27A simple but flexible plugin system for Python.
https://github.com/mitsuhiko/pluginbase
A simple but flexible plugin system for Python. Contribute to mitsuhiko/pluginbase development by creating an account on GitHub.
- 28eyeD3 is a Python module and command line program for processing ID3 tags. Information about mp3 files (i.e bit rate, sample frequency, play time, etc.) is also provided. The formats supported are ID3v1 (1.0/1.1) and ID3v2 (2.3/2.4).
https://github.com/nicfit/eyeD3
eyeD3 is a Python module and command line program for processing ID3 tags. Information about mp3 files (i.e bit rate, sample frequency, play time, etc.) is also provided. The formats supported are ...
- 29dogpile.cache is a Python caching API which provides a generic interface to caching backends of any variety
https://github.com/sqlalchemy/dogpile.cache
dogpile.cache is a Python caching API which provides a generic interface to caching backends of any variety - sqlalchemy/dogpile.cache
- 30Panda3D | Open Source Framework for 3D Rendering & Games
https://www.panda3d.org/
Panda3D is an open-source, cross-platform, completely free-to-use engine for realtime 3D games, visualizations, simulations, experiments — you name it! Its rich feature set readily tailors to your specific workflow and development needs.
- 31mimetypes — Map filenames to MIME types
https://docs.python.org/3/library/mimetypes.html
Source code: Lib/mimetypes.py The mimetypes module converts between a filename or URL and the MIME type associated with the filename extension. Conversions are provided from filename to MIME type a...
- 32music library manager and MusicBrainz tagger
https://github.com/beetbox/beets
music library manager and MusicBrainz tagger. Contribute to beetbox/beets development by creating an account on GitHub.
- 33Ansible is a radically simple IT automation platform that makes your applications and systems easier to deploy and maintain. Automate everything from code deployment to network configuration to cloud management, in a language that approaches plain English, using SSH, with no agents to install on remote systems. https://docs.ansible.com.
https://github.com/ansible/ansible
Ansible is a radically simple IT automation platform that makes your applications and systems easier to deploy and maintain. Automate everything from code deployment to network configuration to clo...
- 34Python CLI utility and library for manipulating SQLite databases
https://github.com/simonw/sqlite-utils
Python CLI utility and library for manipulating SQLite databases - simonw/sqlite-utils
- 35Asset management for Python web development.
https://github.com/miracle2k/webassets
Asset management for Python web development. Contribute to miracle2k/webassets development by creating an account on GitHub.
- 36JSON Web Token implementation in Python
https://github.com/jpadilla/pyjwt
JSON Web Token implementation in Python. Contribute to jpadilla/pyjwt development by creating an account on GitHub.
- 37Python Classes Without Boilerplate
https://github.com/python-attrs/attrs
Python Classes Without Boilerplate. Contribute to python-attrs/attrs development by creating an account on GitHub.
- 38Basic Utilities for PyTorch Natural Language Processing (NLP)
https://github.com/PetrochukM/PyTorch-NLP
Basic Utilities for PyTorch Natural Language Processing (NLP) - PetrochukM/PyTorch-NLP
- 39A Python library that generates static type annotations by collecting runtime types
https://github.com/Instagram/MonkeyType
A Python library that generates static type annotations by collecting runtime types - Instagram/MonkeyType
- 40Collection of awesome Python types, stubs, plugins, and tools to work with them.
https://github.com/typeddjango/awesome-python-typing
Collection of awesome Python types, stubs, plugins, and tools to work with them. - typeddjango/awesome-python-typing
- 41Streamlit — A faster way to build and share data apps.
https://github.com/streamlit/streamlit
Streamlit — A faster way to build and share data apps. - streamlit/streamlit
- 42Project Jupyter
https://jupyter.org
The Jupyter Notebook is a web-based interactive computing platform. The notebook combines live code, equations, narrative text, visualizations, interactive dashboards and other media.
- 43Python library that provides a method of accessing lists and dicts with a dotted path notation.
https://github.com/carlosescri/DottedDict
Python library that provides a method of accessing lists and dicts with a dotted path notation. - carlosescri/DottedDict
- 44Postgres CLI with autocompletion and syntax highlighting
https://github.com/dbcli/pgcli
Postgres CLI with autocompletion and syntax highlighting - dbcli/pgcli
- 45MySQL for Python
https://sourceforge.net/projects/mysql-python/
Download MySQL for Python for free. MySQL database connector for Python programming. MySQLdb is a Python DB API-2.0-compliant interface; see PEP-249 for details.
- 46Real-time monitor and web admin for Celery distributed task queue
https://github.com/mher/flower
Real-time monitor and web admin for Celery distributed task queue - mher/flower
- 47Concurrent networking library for Python
https://github.com/eventlet/eventlet
Concurrent networking library for Python. Contribute to eventlet/eventlet development by creating an account on GitHub.
- 48Python Sorted Container Types: Sorted List, Sorted Dict, and Sorted Set
https://github.com/grantjenks/python-sortedcontainers
Python Sorted Container Types: Sorted List, Sorted Dict, and Sorted Set - grantjenks/python-sortedcontainers
- 49🖥️ Session manager for tmux, build on libtmux.
https://github.com/tmux-python/tmuxp
🖥️ Session manager for tmux, build on libtmux. Contribute to tmux-python/tmuxp development by creating an account on GitHub.
- 50Application Framework for Python
https://github.com/datafolklabs/cement
Application Framework for Python. Contribute to datafolklabs/cement development by creating an account on GitHub.
- 51Python disk-backed cache (Django-compatible). Faster than Redis and Memcached. Pure-Python.
https://github.com/grantjenks/python-diskcache
Python disk-backed cache (Django-compatible). Faster than Redis and Memcached. Pure-Python. - grantjenks/python-diskcache
- 52Library for building powerful interactive command line applications in Python
https://github.com/prompt-toolkit/python-prompt-toolkit
Library for building powerful interactive command line applications in Python - prompt-toolkit/python-prompt-toolkit
- 53It's not just a linter that annoys you!
https://github.com/pylint-dev/pylint
It's not just a linter that annoys you! Contribute to pylint-dev/pylint development by creating an account on GitHub.
- 54logging — Logging facility for Python
https://docs.python.org/3/library/logging.html
Source code: Lib/logging/__init__.py Important: This page contains the API reference information. For tutorial information and discussion of more advanced topics, see Basic Tutorial, Advanced Tutor...
- 55pathlib — Object-oriented filesystem paths
https://docs.python.org/3/library/pathlib.html
Source code: Lib/pathlib.py This module offers classes representing filesystem paths with semantics appropriate for different operating systems. Path classes are divided between pure paths, which p...
- 56subprocess — Subprocess management
https://docs.python.org/3/library/subprocess.html
Source code: Lib/subprocess.py The subprocess module allows you to spawn new processes, connect to their input/output/error pipes, and obtain their return codes. This module intends to replace seve...
- 57unittest — Unit testing framework
https://docs.python.org/3/library/unittest.html
Source code: Lib/unittest/__init__.py(If you are already familiar with the basic concepts of testing, you might want to skip to the list of assert methods.) The unittest unit testing framework was ...
- 58Python 3+ compatible port of the configobj library
https://github.com/DiffSK/configobj
Python 3+ compatible port of the configobj library - DiffSK/configobj
- 59CLI for SQLite Databases with auto-completion and syntax highlighting
https://github.com/dbcli/litecli
CLI for SQLite Databases with auto-completion and syntax highlighting - dbcli/litecli
- 60A library for audio and music analysis, feature extraction.
https://github.com/libAudioFlux/audioFlux
A library for audio and music analysis, feature extraction. - libAudioFlux/audioFlux
- 61Dead simple CLI tool to try Python packages - It's never been easier!
https://github.com/timofurrer/try
Dead simple CLI tool to try Python packages - It's never been easier! :package: - GitHub - timofurrer/try: Dead simple CLI tool to try Python packages - It's never been easier!
- 62Pretty good call graphs for dynamic languages
https://github.com/scottrogowski/code2flow
Pretty good call graphs for dynamic languages. Contribute to scottrogowski/code2flow development by creating an account on GitHub.
- 63A cross platform package to do curses-like operations, plus higher level APIs and widgets to create text UIs and ASCII art animations
https://github.com/peterbrittain/asciimatics
A cross platform package to do curses-like operations, plus higher level APIs and widgets to create text UIs and ASCII art animations - peterbrittain/asciimatics
- 64Python Audio Analysis Library: Feature Extraction, Classification, Segmentation and Applications
https://github.com/tyiannak/pyAudioAnalysis
Python Audio Analysis Library: Feature Extraction, Classification, Segmentation and Applications - tyiannak/pyAudioAnalysis
- 65Multilingual text (NLP) processing toolkit
https://github.com/aboSamoor/polyglot
Multilingual text (NLP) processing toolkit . Contribute to aboSamoor/polyglot development by creating an account on GitHub.
- 66PathPicker accepts a wide range of input -- output from git commands, grep results, searches -- pretty much anything. After parsing the input, PathPicker presents you with a nice UI to select which files you're interested in. After that you can open them in your favorite editor or execute arbitrary commands.
https://github.com/facebook/PathPicker
PathPicker accepts a wide range of input -- output from git commands, grep results, searches -- pretty much anything. After parsing the input, PathPicker presents you with a nice UI to select which...
- 67Cross-platform Python Framework for NUI
https://kivy.org/
Open source Python framework for rapid development of applications that make use of innovative user interfaces, such as multi-touch apps.
- 68Python library for audio and music analysis
https://github.com/librosa/librosa
Python library for audio and music analysis. Contribute to librosa/librosa development by creating an account on GitHub.
- 69Easy-to-use data handling for SQL data stores with support for implicit table creation, bulk loading, and transactions.
https://github.com/pudo/dataset
Easy-to-use data handling for SQL data stores with support for implicit table creation, bulk loading, and transactions. - pudo/dataset
- 70A Python wrapper around the libmemcached interface from TangentOrg.
https://github.com/lericson/pylibmc
A Python wrapper around the libmemcached interface from TangentOrg. - GitHub - lericson/pylibmc: A Python wrapper around the libmemcached interface from TangentOrg.
- 71Developer-friendly asynchrony for Django
https://github.com/django/channels
Developer-friendly asynchrony for Django. Contribute to django/channels development by creating an account on GitHub.
- 72Buildout is a deployment automation tool written in and extended with Python
https://github.com/buildout/buildout
Buildout is a deployment automation tool written in and extended with Python - buildout/buildout
- 73WebSocket and WAMP in Python for Twisted and asyncio
https://github.com/crossbario/autobahn-python
WebSocket and WAMP in Python for Twisted and asyncio - crossbario/autobahn-python
- 74A Terminal Client for MySQL with AutoCompletion and Syntax Highlighting.
https://github.com/dbcli/mycli
A Terminal Client for MySQL with AutoCompletion and Syntax Highlighting. - dbcli/mycli
- 75A Python library that provides an easy way to identify devices like mobile phones, tablets and their capabilities by parsing (browser) user agent strings.
https://github.com/selwin/python-user-agents
A Python library that provides an easy way to identify devices like mobile phones, tablets and their capabilities by parsing (browser) user agent strings. - selwin/python-user-agents
- 76Python library and shell utilities to monitor filesystem events.
https://github.com/gorakhargosh/watchdog
Python library and shell utilities to monitor filesystem events. - gorakhargosh/watchdog
- 77A Django content management system focused on flexibility and user experience
https://github.com/wagtail/wagtail
A Django content management system focused on flexibility and user experience - wagtail/wagtail
- 78A generic, spec-compliant, thorough implementation of the OAuth request-signing logic
https://github.com/oauthlib/oauthlib
A generic, spec-compliant, thorough implementation of the OAuth request-signing logic - oauthlib/oauthlib
- 79radar
https://pypi.org/project/radar/
Generate random date(time).
- 80Modularity, scalability & security for your business
http://www.tryton.org/
TRYTON is business software, ideal for companies of any size, easy to use, complete and 100% Open Source.
- 81unittest.mock — mock object library
https://docs.python.org/3/library/unittest.mock.html
Source code: Lib/unittest/mock.py unittest.mock is a library for testing in Python. It allows you to replace parts of your system under test with mock objects and make assertions about how they hav...
- 82Official home for the pymssql source code.
https://github.com/pymssql/pymssql
Official home for the pymssql source code. Contribute to pymssql/pymssql development by creating an account on GitHub.
- 83Ajenti Core and stock plugins
https://github.com/ajenti/ajenti
Ajenti Core and stock plugins. Contribute to ajenti/ajenti development by creating an account on GitHub.
- 84instant coding answers via the command line
https://github.com/gleitz/howdoi
instant coding answers via the command line. Contribute to gleitz/howdoi development by creating an account on GitHub.
- 85A PyPI mirror client according to PEP 381 http://www.python.org/dev/peps/pep-0381/
https://github.com/pypa/bandersnatch/
A PyPI mirror client according to PEP 381 http://www.python.org/dev/peps/pep-0381/ - pypa/bandersnatch
- 86Indico - A feature-rich event management system, made @ CERN, the place where the Web was born.
https://github.com/indico/indico
Indico - A feature-rich event management system, made @ CERN, the place where the Web was born. - indico/indico
- 87concurrent.futures — Launching parallel tasks
https://docs.python.org/3/library/concurrent.futures.html
Source code: Lib/concurrent/futures/thread.py and Lib/concurrent/futures/process.py The concurrent.futures module provides a high-level interface for asynchronously executing callables. The asynchr...
- 88HermesCache
https://pypi.org/project/HermesCache/
Python caching library with tag-based invalidation and dogpile effect prevention
- 89Unidecode
https://pypi.org/project/Unidecode/
ASCII transliterations of Unicode text
- 90Web Scraping Framework
https://github.com/lorien/grab
Web Scraping Framework. Contribute to lorien/grab development by creating an account on GitHub.
- 91Python object-oriented database
https://github.com/zopefoundation/ZODB
Python object-oriented database. Contribute to zopefoundation/ZODB development by creating an account on GitHub.
- 92The Python programming language
https://github.com/python/cpython
The Python programming language. Contribute to python/cpython development by creating an account on GitHub.
- 93Minimal examples of data structures and algorithms in Python
https://github.com/keon/algorithms
Minimal examples of data structures and algorithms in Python - keon/algorithms
- 94GeoDjango | Django documentation
https://docs.djangoproject.com/en/dev/ref/contrib/gis/
The web framework for perfectionists with deadlines.
- 95flake8 is a python tool that glues together pycodestyle, pyflakes, mccabe, and third-party plugins to check the style and quality of some python code.
https://github.com/PyCQA/flake8
flake8 is a python tool that glues together pycodestyle, pyflakes, mccabe, and third-party plugins to check the style and quality of some python code. - PyCQA/flake8
- 96datetime — Basic date and time types
https://docs.python.org/3/library/datetime.html
Source code: Lib/datetime.py The datetime module supplies classes for manipulating dates and times. While date and time arithmetic is supported, the focus of the implementation is on efficient attr...
- 97sqlite3 — DB-API 2.0 interface for SQLite databases
https://docs.python.org/3/library/sqlite3.html
Source code: Lib/sqlite3/ SQLite is a C library that provides a lightweight disk-based database that doesn’t require a separate server process and allows accessing the database using a nonstandard ...
- 98Chef-like functionality for Fabric
https://github.com/sebastien/cuisine
Chef-like functionality for Fabric. Contribute to sebastien/cuisine development by creating an account on GitHub.
- 99A Python module for creating Excel XLSX files.
https://github.com/jmcnamara/XlsxWriter
A Python module for creating Excel XLSX files. Contribute to jmcnamara/XlsxWriter development by creating an account on GitHub.
- 100fastFM: A Library for Factorization Machines
https://github.com/ibayer/fastFM
fastFM: A Library for Factorization Machines. Contribute to ibayer/fastFM development by creating an account on GitHub.
- 101🎚️ Open Source Audio Matching and Mastering
https://github.com/sergree/matchering
🎚️ Open Source Audio Matching and Mastering. Contribute to sergree/matchering development by creating an account on GitHub.
- 102cryptography is a package designed to expose cryptographic primitives and recipes to Python developers.
https://github.com/pyca/cryptography
cryptography is a package designed to expose cryptographic primitives and recipes to Python developers. - pyca/cryptography
- 103pytz
https://pypi.org/project/pytz/
World timezone definitions, modern and historical
- 104A jquery-like library for python
https://github.com/gawel/pyquery
A jquery-like library for python. Contribute to gawel/pyquery development by creating an account on GitHub.
- 105The leading native Python SSHv2 protocol library.
https://github.com/paramiko/paramiko
The leading native Python SSHv2 protocol library. Contribute to paramiko/paramiko development by creating an account on GitHub.
- 106Interactive Redis: A Terminal Client for Redis with AutoCompletion and Syntax Highlighting.
https://github.com/laixintao/iredis
Interactive Redis: A Terminal Client for Redis with AutoCompletion and Syntax Highlighting. - laixintao/iredis
- 107PyPy / pypy · GitLab
https://foss.heptapod.net/pypy/pypy
PyPy is a very fast and compliant implementation of the Python language.
- 108Performant type-checking for python.
https://github.com/facebook/pyre-check
Performant type-checking for python. Contribute to facebook/pyre-check development by creating an account on GitHub.
- 109A collection of design patterns/idioms in Python
https://github.com/faif/python-patterns
A collection of design patterns/idioms in Python. Contribute to faif/python-patterns development by creating an account on GitHub.
- 110🎨 Generate and change color-schemes on the fly.
https://github.com/dylanaraps/pywal
🎨 Generate and change color-schemes on the fly. Contribute to dylanaraps/pywal development by creating an account on GitHub.
- 111SCons - a software construction tool
https://github.com/SCons/scons
SCons - a software construction tool. Contribute to SCons/scons development by creating an account on GitHub.
- 112cross-library (GStreamer + Core Audio + MAD + FFmpeg) audio decoding for Python
https://github.com/beetbox/audioread
cross-library (GStreamer + Core Audio + MAD + FFmpeg) audio decoding for Python - beetbox/audioread
- 113Simple tagging for django
https://github.com/jazzband/django-taggit
Simple tagging for django. Contribute to jazzband/django-taggit development by creating an account on GitHub.
- 114Pipeline is an asset packaging library for Django.
https://github.com/jazzband/django-pipeline
Pipeline is an asset packaging library for Django. - jazzband/django-pipeline
- 115A Django app that creates automatic web UIs for Python scripts.
https://github.com/wooey/wooey
A Django app that creates automatic web UIs for Python scripts. - wooey/Wooey
- 116The ultimate Python library in building OAuth, OpenID Connect clients and servers. JWS,JWE,JWK,JWA,JWT included.
https://github.com/lepture/authlib
The ultimate Python library in building OAuth, OpenID Connect clients and servers. JWS,JWE,JWK,JWA,JWT included. - lepture/authlib
- 117Python Fire is a library for automatically generating command line interfaces (CLIs) from absolutely any Python object.
https://github.com/google/python-fire
Python Fire is a library for automatically generating command line interfaces (CLIs) from absolutely any Python object. - google/python-fire
- 118kapre: Keras Audio Preprocessors
https://github.com/keunwoochoi/kapre
kapre: Keras Audio Preprocessors. Contribute to keunwoochoi/kapre development by creating an account on GitHub.
- 119The official bitbake Git is at https://git.openembedded.org/bitbake/. Do not open issues or file pull requests here.
https://github.com/openembedded/bitbake
The official bitbake Git is at https://git.openembedded.org/bitbake/. Do not open issues or file pull requests here. - openembedded/bitbake
- 120Apache Kafka
https://kafka.apache.org/documentation/streams/
Apache Kafka: A Distributed Streaming Platform.
- 121the Python IDE for data science and web development
https://www.jetbrains.com/pycharm/
The Python IDE for data science and web development with intelligent code completion, on-the-fly error checking, quick-fixes, and much more.
- 122㊙️ Create standard barcodes with Python. No external dependencies. 100% Organic Python.
https://github.com/WhyNotHugo/python-barcode
㊙️ Create standard barcodes with Python. No external dependencies. 100% Organic Python. - WhyNotHugo/python-barcode
- 123Standards-compliant library for parsing and serializing HTML documents and fragments in Python
https://github.com/html5lib/html5lib-python
Standards-compliant library for parsing and serializing HTML documents and fragments in Python - html5lib/html5lib-python
- 124A curated list of awesome PostgreSQL software, libraries, tools and resources, inspired by awesome-mysql
https://github.com/dhamaniasad/awesome-postgres
A curated list of awesome PostgreSQL software, libraries, tools and resources, inspired by awesome-mysql - dhamaniasad/awesome-postgres
- 125plotting in the terminal
https://github.com/glamp/bashplotlib
plotting in the terminal. Contribute to glamp/bashplotlib development by creating an account on GitHub.
- 126Hydra is a framework for elegantly configuring complex applications
https://github.com/facebookresearch/hydra
Hydra is a framework for elegantly configuring complex applications - facebookresearch/hydra
- 127All Algorithms implemented in Python
https://github.com/TheAlgorithms/Python
All Algorithms implemented in Python. Contribute to TheAlgorithms/Python development by creating an account on GitHub.
- 128scalable audio processing framework and server written in Python
https://github.com/Parisson/TimeSide
scalable audio processing framework and server written in Python - Parisson/TimeSide
- 129The uncompromising Python code formatter
https://github.com/psf/black
The uncompromising Python code formatter. Contribute to psf/black development by creating an account on GitHub.
- 130Python composable command line interface toolkit
https://github.com/pallets/click/
Python composable command line interface toolkit. Contribute to pallets/click development by creating an account on GitHub.
- 131Write scalable load tests in plain Python 🚗💨
https://github.com/locustio/locust
Write scalable load tests in plain Python 🚗💨. Contribute to locustio/locust development by creating an account on GitHub.
- 132An ASGI web server, for Python. 🦄
https://github.com/encode/uvicorn
An ASGI web server, for Python. 🦄. Contribute to encode/uvicorn development by creating an account on GitHub.
- 133Collection of library stubs for Python, with static types
https://github.com/python/typeshed
Collection of library stubs for Python, with static types - python/typeshed
- 134Intercept HTTP requests at the Python socket level. Fakes the whole socket module
https://github.com/gabrielfalcao/HTTPretty
Intercept HTTP requests at the Python socket level. Fakes the whole socket module - gabrielfalcao/HTTPretty
- 135Audio fingerprinting and recognition in Python
https://github.com/worldveil/dejavu
Audio fingerprinting and recognition in Python. Contribute to worldveil/dejavu development by creating an account on GitHub.
- 136Rich is a Python library for rich text and beautiful formatting in the terminal.
https://github.com/Textualize/rich
Rich is a Python library for rich text and beautiful formatting in the terminal. - Textualize/rich
- 137Bowler · Safe code refactoring for modern Python
https://pybowler.io/
Safe code refactoring for modern Python
- 138:truck: Agile Data Preparation Workflows made easy with Pandas, Dask, cuDF, Dask-cuDF, Vaex and PySpark
https://github.com/hi-primus/optimus
:truck: Agile Data Preparation Workflows made easy with Pandas, Dask, cuDF, Dask-cuDF, Vaex and PySpark - hi-primus/optimus
- 139Python binding to the Networking and Cryptography (NaCl) library
https://github.com/pyca/pynacl
Python binding to the Networking and Cryptography (NaCl) library - pyca/pynacl
- 140MicroPython - a lean and efficient Python implementation for microcontrollers and constrained systems
https://github.com/micropython/micropython
MicroPython - a lean and efficient Python implementation for microcontrollers and constrained systems - micropython/micropython
- 141Manipulate audio with a simple and easy high level interface
https://github.com/jiaaro/pydub
Manipulate audio with a simple and easy high level interface - jiaaro/pydub
- 142Event-driven networking engine written in Python.
https://github.com/twisted/twisted
Event-driven networking engine written in Python. Contribute to twisted/twisted development by creating an account on GitHub.
- 143Qt | Tools for Each Stage of Software Development Lifecycle
https://www.qt.io/
All the essential Qt tools for all stages of Software Development Lifecycle: planning, design, development, testing, and deployment.
- 144spaCy · Industrial-strength Natural Language Processing in Python
https://spacy.io/
spaCy is a free open-source library for Natural Language Processing in Python. It features NER, POS tagging, dependency parsing, word vectors and more.
- 145A new kind of Progress Bar, with real-time throughput, ETA, and very cool animations!
https://github.com/rsalmei/alive-progress
A new kind of Progress Bar, with real-time throughput, ETA, and very cool animations! - rsalmei/alive-progress
- 146team-simpy / simpy · GitLab
https://gitlab.com/team-simpy/simpy
GitLab.com
- 147Lightweight, extensible data validation library for Python
https://github.com/pyeve/cerberus
Lightweight, extensible data validation library for Python - pyeve/cerberus
- 148A simple library for implementing common design patterns.
https://github.com/tylerlaberge/PyPattyrn
A simple library for implementing common design patterns. - tylerlaberge/PyPattyrn
- 149Strict separation of config from code.
https://github.com/HBNetwork/python-decouple
Strict separation of config from code. Contribute to HBNetwork/python-decouple development by creating an account on GitHub.
- 150A Django-based CMS with a focus on extensibility and concise code
https://github.com/feincms/feincms
A Django-based CMS with a focus on extensibility and concise code - feincms/feincms
- 151Tensors and Dynamic neural networks in Python with strong GPU acceleration
https://github.com/pytorch/pytorch
Tensors and Dynamic neural networks in Python with strong GPU acceleration - pytorch/pytorch
- 152Software build automation tool for Python.
https://github.com/pybuilder/pybuilder
Software build automation tool for Python. Contribute to pybuilder/pybuilder development by creating an account on GitHub.
- 153Geometric Computer Vision Library for Spatial AI
https://github.com/kornia/kornia/
Geometric Computer Vision Library for Spatial AI. Contribute to kornia/kornia development by creating an account on GitHub.
- 154Find dead Python code
https://github.com/jendrikseipp/vulture
Find dead Python code. Contribute to jendrikseipp/vulture development by creating an account on GitHub.
- 155Python module for handling audio metadata
https://github.com/quodlibet/mutagen
Python module for handling audio metadata. Contribute to quodlibet/mutagen development by creating an account on GitHub.
- 156A static type analyzer for Python code
https://github.com/google/pytype
A static type analyzer for Python code. Contribute to google/pytype development by creating an account on GitHub.
- 157Python for .NET is a package that gives Python programmers nearly seamless integration with the .NET Common Language Runtime (CLR) and provides a powerful application scripting tool for .NET developers.
https://github.com/pythonnet/pythonnet
Python for .NET is a package that gives Python programmers nearly seamless integration with the .NET Common Language Runtime (CLR) and provides a powerful application scripting tool for .NET develo...
- 158tmux source code
https://github.com/tmux/tmux
tmux source code. Contribute to tmux/tmux development by creating an account on GitHub.
- 159Ultra fast asyncio event loop.
https://github.com/MagicStack/uvloop
Ultra fast asyncio event loop. Contribute to MagicStack/uvloop development by creating an account on GitHub.
- 160Motor - the async Python driver for MongoDB and Tornado or asyncio
https://github.com/mongodb/motor
Motor - the async Python driver for MongoDB and Tornado or asyncio - mongodb/motor
- 161Official s3cmd repo -- Command line tool for managing S3 compatible storage services (including Amazon S3 and CloudFront).
https://github.com/s3tools/s3cmd
Official s3cmd repo -- Command line tool for managing S3 compatible storage services (including Amazon S3 and CloudFront). - s3tools/s3cmd
- 162Awesome Django authorization, without the database
https://github.com/dfunckt/django-rules
Awesome Django authorization, without the database - dfunckt/django-rules
- 163Ready-to-use OCR with 80+ supported languages and all popular writing scripts including Latin, Chinese, Arabic, Devanagari, Cyrillic and etc.
https://github.com/JaidedAI/EasyOCR
Ready-to-use OCR with 80+ supported languages and all popular writing scripts including Latin, Chinese, Arabic, Devanagari, Cyrillic and etc. - JaidedAI/EasyOCR
- 164pandas on AWS - Easy integration with Athena, Glue, Redshift, Timestream, Neptune, OpenSearch, QuickSight, Chime, CloudWatchLogs, DynamoDB, EMR, SecretManager, PostgreSQL, MySQL, SQLServer and S3 (Parquet, CSV, JSON and EXCEL).
https://github.com/aws/aws-sdk-pandas
pandas on AWS - Easy integration with Athena, Glue, Redshift, Timestream, Neptune, OpenSearch, QuickSight, Chime, CloudWatchLogs, DynamoDB, EMR, SecretManager, PostgreSQL, MySQL, SQLServer and S3 (...
- 165Optional static typing for Python
https://github.com/python/mypy
Optional static typing for Python. Contribute to python/mypy development by creating an account on GitHub.
- 166A JOSE implementation in Python
https://github.com/mpdavis/python-jose/
A JOSE implementation in Python. Contribute to mpdavis/python-jose development by creating an account on GitHub.
- 167Errbot is a chatbot, a daemon that connects to your favorite chat service and bring your tools and some fun into the conversation.
https://github.com/errbotio/errbot/
Errbot is a chatbot, a daemon that connects to your favorite chat service and bring your tools and some fun into the conversation. - errbotio/errbot
- 168No non-sense and no BS repo for how data structure code should be in Python - simple and elegant.
https://github.com/prabhupant/python-ds
No non-sense and no BS repo for how data structure code should be in Python - simple and elegant. - prabhupant/python-ds
- 169OAuth2 goodies for the Djangonauts!
https://github.com/jazzband/django-oauth-toolkit
OAuth2 goodies for the Djangonauts! Contribute to jazzband/django-oauth-toolkit development by creating an account on GitHub.
- 170Python Stream Processing
https://github.com/robinhood/faust
Python Stream Processing. Contribute to robinhood/faust development by creating an account on GitHub.
- 171Apache Libcloud is a standard Python library that abstracts away differences among multiple cloud provider APIs
https://libcloud.apache.org/
Python library for interacting with many of the popular cloud service providers using a unified API.
- 172结巴中文分词
https://github.com/fxsjy/jieba
结巴中文分词. Contribute to fxsjy/jieba development by creating an account on GitHub.
- 173The bidirectional mapping library for Python.
https://github.com/jab/bidict
The bidirectional mapping library for Python. Contribute to jab/bidict development by creating an account on GitHub.
- 174A curated list of awesome Python asyncio frameworks, libraries, software and resources
https://github.com/timofurrer/awesome-asyncio
A curated list of awesome Python asyncio frameworks, libraries, software and resources - timofurrer/awesome-asyncio
- 175🥧 HTTPie CLI — modern, user-friendly command-line HTTP client for the API era. JSON support, colors, sessions, downloads, plugins & more.
https://github.com/httpie/cli
🥧 HTTPie CLI — modern, user-friendly command-line HTTP client for the API era. JSON support, colors, sessions, downloads, plugins & more. - httpie/cli
- 176:octocat: A curated awesome list of flake8 extensions. Feel free to contribute! :mortar_board:
https://github.com/DmytroLitvinov/awesome-flake8-extensions
:octocat: A curated awesome list of flake8 extensions. Feel free to contribute! :mortar_board: - DmytroLitvinov/awesome-flake8-extensions
- 177A curated list of awesome Flask resources and plugins
https://github.com/humiaozuzu/awesome-flask
A curated list of awesome Flask resources and plugins - humiaozuzu/awesome-flask
- 178Magnificent app which corrects your previous console command.
https://github.com/nvbn/thefuck
Magnificent app which corrects your previous console command. - nvbn/thefuck
- 179Python requests like API built on top of Twisted's HTTP client.
https://github.com/twisted/treq
Python requests like API built on top of Twisted's HTTP client. - twisted/treq
- 180:art: Diagram as Code for prototyping cloud system architectures
https://github.com/mingrammer/diagrams
:art: Diagram as Code for prototyping cloud system architectures - mingrammer/diagrams
- 181SQLAlchemy
https://www.sqlalchemy.org/
The Database Toolkit for Python
- 182Accelerate your web app development | Build fast. Run fast.
https://github.com/sanic-org/sanic
Accelerate your web app development | Build fast. Run fast. - sanic-org/sanic
- 183structlog
https://www.structlog.org/en/stable/
Simple. Powerful. Fast. Pick three. Release 24.4.0( What’s new?) structlog is the production-ready logging solution for Python: Simple: Everything is about functions that take and return dictionari...
- 184Python for Windows (pywin32) Extensions
https://github.com/mhammond/pywin32
Python for Windows (pywin32) Extensions. Contribute to mhammond/pywin32 development by creating an account on GitHub.
- 185MySQL client library for Python
https://github.com/PyMySQL/PyMySQL
MySQL client library for Python. Contribute to PyMySQL/PyMySQL development by creating an account on GitHub.
- 186Your Gateway to Embedded Software Development Excellence :alien:
https://github.com/platformio/platformio-core
Your Gateway to Embedded Software Development Excellence :alien: - platformio/platformio-core
- 187Build software better, together
https://github.com/tesseract-ocr.
GitHub is where people build software. More than 100 million people use GitHub to discover, fork, and contribute to over 420 million projects.
- 188An open source multi-tool for exploring and publishing data
https://github.com/simonw/datasette
An open source multi-tool for exploring and publishing data - simonw/datasette
- 189A curated list of awesome tools for Sphinx Python Documentation Generator
https://github.com/yoloseem/awesome-sphinxdoc
A curated list of awesome tools for Sphinx Python Documentation Generator - yoloseem/awesome-sphinxdoc
- 190A cross-platform command-line utility that creates projects from cookiecutters (project templates), e.g. Python package projects, C projects.
https://github.com/cookiecutter/cookiecutter
A cross-platform command-line utility that creates projects from cookiecutters (project templates), e.g. Python package projects, C projects. - cookiecutter/cookiecutter
- 191Trio – a friendly Python library for async concurrency and I/O
https://github.com/python-trio/trio
Trio – a friendly Python library for async concurrency and I/O - python-trio/trio
- 192Paranoid text spacing in Python
https://github.com/vinta/pangu.py
Paranoid text spacing in Python. Contribute to vinta/pangu.py development by creating an account on GitHub.
- 193Pythonic task management & command execution.
https://github.com/pyinvoke/invoke
Pythonic task management & command execution. Contribute to pyinvoke/invoke development by creating an account on GitHub.
- 194Python Tools for Visual Studio
https://github.com/Microsoft/PTVS
Python Tools for Visual Studio. Contribute to microsoft/PTVS development by creating an account on GitHub.
- 195Jet Admin – No-code Business App builder
https://github.com/jet-admin/jet-bridge
Jet Admin – No-code Business App builder. Contribute to jet-admin/jet-bridge development by creating an account on GitHub.
- 196Home
https://opencv.org/
OpenCV provides a real-time optimized Computer Vision library, tools, and hardware. It also supports model execution for Machine Learning (ML) and Artificial Intelligence (AI).
- 197HARFANG® 3D - Real Time Visualization Tools
http://www.harfang3d.com
Software framework for modern multimedia application development.
- 198Python email address and Mime parsing library
https://github.com/mailgun/flanker
Python email address and Mime parsing library. Contribute to mailgun/flanker development by creating an account on GitHub.
- 199shiv is a command line utility for building fully self contained Python zipapps as outlined in PEP 441, but with all their dependencies included.
https://github.com/linkedin/shiv
shiv is a command line utility for building fully self contained Python zipapps as outlined in PEP 441, but with all their dependencies included. - linkedin/shiv
- 200Ray is a unified framework for scaling AI and Python applications. Ray consists of a core distributed runtime and a set of AI Libraries for accelerating ML workloads.
https://github.com/ray-project/ray/
Ray is a unified framework for scaling AI and Python applications. Ray consists of a core distributed runtime and a set of AI Libraries for accelerating ML workloads. - ray-project/ray
- 201MySQL database connector for Python (with Python 3 support)
https://github.com/PyMySQL/mysqlclient
MySQL database connector for Python (with Python 3 support) - PyMySQL/mysqlclient
- 202Generate generic activity streams from the actions on your site. Users can follow any actors' activities for personalized streams.
https://github.com/justquick/django-activity-stream
Generate generic activity streams from the actions on your site. Users can follow any actors' activities for personalized streams. - justquick/django-activity-stream
- 203A collection of awesome sqlite tools, scripts, books, etc
https://github.com/planetopendata/awesome-sqlite
A collection of awesome sqlite tools, scripts, books, etc - planetopendata/awesome-sqlite
- 204Make your functions return something meaningful, typed, and safe!
https://github.com/dry-python/returns
Make your functions return something meaningful, typed, and safe! - dry-python/returns
- 205Ultra fast JSON decoder and encoder written in C with Python bindings
https://github.com/esnme/ultrajson
Ultra fast JSON decoder and encoder written in C with Python bindings - ultrajson/ultrajson
- 206FastAPI framework, high performance, easy to learn, fast to code, ready for production
https://github.com/tiangolo/fastapi
FastAPI framework, high performance, easy to learn, fast to code, ready for production - fastapi/fastapi
- 207A code-completion engine for Vim
https://github.com/Valloric/YouCompleteMe
A code-completion engine for Vim. Contribute to ycm-core/YouCompleteMe development by creating an account on GitHub.
- 208Build software better, together
https://github.com/python-greenlet/greenlet.
GitHub is where people build software. More than 100 million people use GitHub to discover, fork, and contribute to over 420 million projects.
- 209A serialization/deserialization/validation library for strings, mappings and lists.
https://github.com/Pylons/colander
A serialization/deserialization/validation library for strings, mappings and lists. - Pylons/colander
- 210pickleDB is an open source key-value store using Python's json module.
https://github.com/patx/pickledb
pickleDB is an open source key-value store using Python's json module. - patx/pickledb
- 211Python library for processing Chinese text
https://github.com/isnowfy/snownlp
Python library for processing Chinese text. Contribute to isnowfy/snownlp development by creating an account on GitHub.
- 212Fast Python Collaborative Filtering for Implicit Feedback Datasets
https://github.com/benfred/implicit
Fast Python Collaborative Filtering for Implicit Feedback Datasets - benfred/implicit
- 213Web mining module for Python, with tools for scraping, natural language processing, machine learning, network analysis and visualization.
https://github.com/clips/pattern
Web mining module for Python, with tools for scraping, natural language processing, machine learning, network analysis and visualization. - clips/pattern
- 214pkuseg多领域中文分词工具; The pkuseg toolkit for multi-domain Chinese word segmentation
https://github.com/lancopku/pkuseg-python
pkuseg多领域中文分词工具; The pkuseg toolkit for multi-domain Chinese word segmentation - lancopku/pkuseg-python
- 215fsociety Hacking Tools Pack – A Penetration Testing Framework
https://github.com/Manisso/fsociety
fsociety Hacking Tools Pack – A Penetration Testing Framework - Manisso/fsociety
- 216The Sphinx documentation generator
https://github.com/sphinx-doc/sphinx/
The Sphinx documentation generator. Contribute to sphinx-doc/sphinx development by creating an account on GitHub.
- 217Simple, Pythonic remote execution and deployment.
https://github.com/fabric/fabric
Simple, Pythonic remote execution and deployment. Contribute to fabric/fabric development by creating an account on GitHub.
- 218Simple framework for creating REST APIs
https://github.com/flask-restful/flask-restful
Simple framework for creating REST APIs. Contribute to flask-restful/flask-restful development by creating an account on GitHub.
- 219Deep Learning for humans
https://github.com/keras-team/keras
Deep Learning for humans. Contribute to keras-team/keras development by creating an account on GitHub.
- 220Redis Python client
https://github.com/redis/redis-py
Redis Python client. Contribute to redis/redis-py development by creating an account on GitHub.
- 221Luigi is a Python module that helps you build complex pipelines of batch jobs. It handles dependency resolution, workflow management, visualization etc. It also comes with Hadoop support built in.
https://github.com/spotify/luigi
Luigi is a Python module that helps you build complex pipelines of batch jobs. It handles dependency resolution, workflow management, visualization etc. It also comes with Hadoop support built in. ...
- 222AKShare is an elegant and simple financial data interface library for Python, built for human beings! 开源财经数据接口库
https://github.com/jindaxiang/akshare
AKShare is an elegant and simple financial data interface library for Python, built for human beings! 开源财经数据接口库 - akfamily/akshare
- 223A Python wrapper for Google Tesseract
https://github.com/madmaze/pytesseract
A Python wrapper for Google Tesseract. Contribute to madmaze/pytesseract development by creating an account on GitHub.
- 224A pythonic interface to Amazon's DynamoDB
https://github.com/pynamodb/PynamoDB
A pythonic interface to Amazon's DynamoDB. Contribute to pynamodb/PynamoDB development by creating an account on GitHub.
- 225A slick ORM cache with automatic granular event-driven invalidation.
https://github.com/Suor/django-cacheops
A slick ORM cache with automatic granular event-driven invalidation. - Suor/django-cacheops
- 226Home
https://airflow.apache.org/
Platform created by the community to programmatically author, schedule and monitor workflows.
- 227Using the jedi autocompletion library for VIM.
https://github.com/davidhalter/jedi-vim
Using the jedi autocompletion library for VIM. Contribute to davidhalter/jedi-vim development by creating an account on GitHub.
- 228Data validation using Python type hints
https://github.com/pydantic/pydantic
Data validation using Python type hints. Contribute to pydantic/pydantic development by creating an account on GitHub.
- 229A Python implementation of LightFM, a hybrid recommendation algorithm.
https://github.com/lyst/lightfm
A Python implementation of LightFM, a hybrid recommendation algorithm. - lyst/lightfm
- 230bpython - A fancy curses interface to the Python interactive interpreter
https://github.com/bpython/bpython
bpython - A fancy curses interface to the Python interactive interpreter - bpython/bpython
- 231Python Data Structures for Humans™.
https://github.com/schematics/schematics
Python Data Structures for Humans™. Contribute to schematics/schematics development by creating an account on GitHub.
- 232Safely pass trusted data to untrusted environments and back.
https://github.com/pallets/itsdangerous
Safely pass trusted data to untrusted environments and back. - pallets/itsdangerous
- 233PYthon svg GrAph plotting Library
https://github.com/Kozea/pygal
PYthon svg GrAph plotting Library. Contribute to Kozea/pygal development by creating an account on GitHub.
- 234The most widely used Python to C compiler
https://github.com/cython/cython
The most widely used Python to C compiler. Contribute to cython/cython development by creating an account on GitHub.
- 235Parallel computing with task scheduling
https://github.com/dask/dask
Parallel computing with task scheduling. Contribute to dask/dask development by creating an account on GitHub.
- 236Dear PyGui: A fast and powerful Graphical User Interface Toolkit for Python with minimal dependencies
https://github.com/RaylockLLC/DearPyGui/
Dear PyGui: A fast and powerful Graphical User Interface Toolkit for Python with minimal dependencies - hoffstadt/DearPyGui
- 237(No longer maintained) A faster and highly-compatible implementation of the Python programming language.
https://github.com/pyston/pyston/
(No longer maintained) A faster and highly-compatible implementation of the Python programming language. - pyston/pyston
- 238matplotlib: plotting with Python
https://github.com/matplotlib/matplotlib
matplotlib: plotting with Python. Contribute to matplotlib/matplotlib development by creating an account on GitHub.
- 239pyglet is a cross-platform windowing and multimedia library for Python, for developing games and other visually rich applications.
https://github.com/pyglet/pyglet
pyglet is a cross-platform windowing and multimedia library for Python, for developing games and other visually rich applications. - pyglet/pyglet
- 240Vim python-mode. PyLint, Rope, Pydoc, breakpoints from box.
https://github.com/python-mode/python-mode
Vim python-mode. PyLint, Rope, Pydoc, breakpoints from box. - python-mode/python-mode
- 241Stanford NLP Python library for tokenization, sentence segmentation, NER, and parsing of many human languages
https://github.com/stanfordnlp/stanza
Stanford NLP Python library for tokenization, sentence segmentation, NER, and parsing of many human languages - stanfordnlp/stanza
- 242Automatic SQL injection and database takeover tool
https://github.com/sqlmapproject/sqlmap
Automatic SQL injection and database takeover tool - sqlmapproject/sqlmap
- 243PyMongo - the Official MongoDB Python driver
https://github.com/mongodb/mongo-python-driver
PyMongo - the Official MongoDB Python driver. Contribute to mongodb/mongo-python-driver development by creating an account on GitHub.
- 244🏹 Better dates & times for Python
https://github.com/arrow-py/arrow
🏹 Better dates & times for Python. Contribute to arrow-py/arrow development by creating an account on GitHub.
- 245A python wrapper for libmagic
https://github.com/ahupp/python-magic
A python wrapper for libmagic. Contribute to ahupp/python-magic development by creating an account on GitHub.
- 246🍦 Never use print() to debug again.
https://github.com/gruns/icecream
🍦 Never use print() to debug again. Contribute to gruns/icecream development by creating an account on GitHub.
- 247A Python native, OS native GUI toolkit.
https://github.com/pybee/toga
A Python native, OS native GUI toolkit. Contribute to beeware/toga development by creating an account on GitHub.
- 248Every web site provides APIs.
https://github.com/gaojiuli/toapi
Every web site provides APIs. Contribute to elliotgao2/toapi development by creating an account on GitHub.
- 249Python packaging and dependency management made easy
https://github.com/sdispater/poetry
Python packaging and dependency management made easy - python-poetry/poetry
- 250Sixpack is a language-agnostic a/b-testing framework
https://github.com/seatgeek/sixpack
Sixpack is a language-agnostic a/b-testing framework - sixpack/sixpack
- 251Object-oriented file system path manipulation
https://github.com/jaraco/path.py
Object-oriented file system path manipulation. Contribute to jaraco/path development by creating an account on GitHub.
- 252Python PyPi staging server and packaging, testing, release tool
https://github.com/devpi/devpi
Python PyPi staging server and packaging, testing, release tool - devpi/devpi
- 253An implementation of the JSON Schema specification for Python
https://github.com/python-jsonschema/jsonschema
An implementation of the JSON Schema specification for Python - python-jsonschema/jsonschema
- 254Approximate Nearest Neighbors in C++/Python optimized for memory usage and loading/saving to disk
https://github.com/spotify/annoy
Approximate Nearest Neighbors in C++/Python optimized for memory usage and loading/saving to disk - spotify/annoy
- 255Implementation of Python 3.x for .NET Framework that is built on top of the Dynamic Language Runtime.
https://github.com/IronLanguages/ironpython3
Implementation of Python 3.x for .NET Framework that is built on top of the Dynamic Language Runtime. - IronLanguages/ironpython3
- 256zerorpc for python
https://github.com/0rpc/zerorpc-python
zerorpc for python. Contribute to 0rpc/zerorpc-python development by creating an account on GitHub.
- 257Freeze (package) Python programs into stand-alone executables
https://github.com/pyinstaller/pyinstaller
Freeze (package) Python programs into stand-alone executables - pyinstaller/pyinstaller
- 258Inspects Python source files and provides information about type and location of classes, methods etc
https://github.com/PyCQA/prospector
Inspects Python source files and provides information about type and location of classes, methods etc - landscapeio/prospector
- 259A Python implementation of John Gruber’s Markdown with Extension support.
https://github.com/waylan/Python-Markdown
A Python implementation of John Gruber’s Markdown with Extension support. - Python-Markdown/markdown
- 260Scapy: the Python-based interactive packet manipulation program & library.
https://github.com/secdev/scapy
Scapy: the Python-based interactive packet manipulation program & library. - secdev/scapy
- 261NumPy aware dynamic Python compiler using LLVM
https://github.com/numba/numba
NumPy aware dynamic Python compiler using LLVM. Contribute to numba/numba development by creating an account on GitHub.
- 262Full-screen console debugger for Python
https://github.com/inducer/pudb
Full-screen console debugger for Python. Contribute to inducer/pudb development by creating an account on GitHub.
- 263The Social-Engineer Toolkit (SET) repository from TrustedSec - All new versions of SET will be deployed here.
https://github.com/trustedsec/social-engineer-toolkit
The Social-Engineer Toolkit (SET) repository from TrustedSec - All new versions of SET will be deployed here. - trustedsec/social-engineer-toolkit
- 264Build software better, together
https://github.com/jonathanslenders/python-prompt-toolkit.
GitHub is where people build software. More than 100 million people use GitHub to discover, fork, and contribute to over 420 million projects.
- 265Create standalone Windows programs from Python code
https://github.com/py2exe/py2exe
Create standalone Windows programs from Python code - py2exe/py2exe
- 266Magenta: Music and Art Generation with Machine Intelligence
https://github.com/magenta/magenta
Magenta: Music and Art Generation with Machine Intelligence - magenta/magenta
- 267Validated, scalable, community developed variant calling, RNA-seq and small RNA analysis
https://github.com/chapmanb/bcbio-nextgen
Validated, scalable, community developed variant calling, RNA-seq and small RNA analysis - bcbio/bcbio-nextgen
- 268No longer maintained, please migrate to model_bakery
https://github.com/vandersonmota/model_mommy
No longer maintained, please migrate to model_bakery - berinhard/model_mommy
- 269Topic Modelling for Humans
https://github.com/RaRe-Technologies/gensim
Topic Modelling for Humans. Contribute to piskvorky/gensim development by creating an account on GitHub.
- 270xlwings is a Python library that makes it easy to call Python from Excel and vice versa. It works with Excel on Windows and macOS as well as with Google Sheets and Excel on the web.
https://github.com/ZoomerAnalytics/xlwings
xlwings is a Python library that makes it easy to call Python from Excel and vice versa. It works with Excel on Windows and macOS as well as with Google Sheets and Excel on the web. - GitHub - xlw...
- 271Build software better, together
https://github.com/mre/awesome-static-analysis.
GitHub is where people build software. More than 100 million people use GitHub to discover, fork, and contribute to over 420 million projects.
- 272A formatter for Python files
https://github.com/google/yapf
A formatter for Python files. Contribute to google/yapf development by creating an account on GitHub.
- 273Simple, elegant, Pythonic functional programming.
https://github.com/evhub/coconut
Simple, elegant, Pythonic functional programming. Contribute to evhub/coconut development by creating an account on GitHub.
- 274The POX network software platform
https://github.com/noxrepo/pox
The POX network software platform. Contribute to noxrepo/pox development by creating an account on GitHub.
- 275Write desktop and web apps in pure Python
https://github.com/zoofIO/flexx
Write desktop and web apps in pure Python. Contribute to flexxui/flexx development by creating an account on GitHub.
- 276py2app is a Python setuptools command which will allow you to make standalone Mac OS X application bundles and plugins from Python scripts.
https://github.com/ronaldoussoren/py2app
py2app is a Python setuptools command which will allow you to make standalone Mac OS X application bundles and plugins from Python scripts. - ronaldoussoren/py2app
- 277Rich Python data types for Redis
https://github.com/stephenmcd/hot-redis
Rich Python data types for Redis. Contribute to stephenmcd/hot-redis development by creating an account on GitHub.
- 278A lightweight, object-oriented finite state machine implementation in Python with many extensions
https://github.com/pytransitions/transitions
A lightweight, object-oriented finite state machine implementation in Python with many extensions - pytransitions/transitions
- 279A Python Mail Server
https://github.com/moggers87/salmon
A Python Mail Server. Contribute to moggers87/salmon development by creating an account on GitHub.
- 280Python client for Apache Kafka
https://github.com/dpkp/kafka-python
Python client for Apache Kafka. Contribute to dpkp/kafka-python development by creating an account on GitHub.
- 281A powerful workflow engine implemented in pure Python
https://github.com/knipknap/SpiffWorkflow
A powerful workflow engine implemented in pure Python - sartography/SpiffWorkflow
- 282Supercharge your API testing, catch bugs, and ensure compliance
https://github.com/kiwicom/schemathesis
Supercharge your API testing, catch bugs, and ensure compliance - schemathesis/schemathesis
- 283The Web framework for perfectionists with deadlines.
https://github.com/django/django
The Web framework for perfectionists with deadlines. - django/django
- 284:zap: A Fast, Extensible Progress Bar for Python and CLI
https://github.com/tqdm/tqdm
:zap: A Fast, Extensible Progress Bar for Python and CLI - tqdm/tqdm
- 285Python job scheduling for humans.
https://github.com/dbader/schedule
Python job scheduling for humans. Contribute to dbader/schedule development by creating an account on GitHub.
- 286Visual profiler for Python
https://github.com/nvdv/vprof
Visual profiler for Python. Contribute to nvdv/vprof development by creating an account on GitHub.
- 287An async ORM. 🗃
https://github.com/encode/orm
An async ORM. 🗃. Contribute to encode/orm development by creating an account on GitHub.
- 288Mail hosting made simple
https://github.com/modoboa/modoboa
Mail hosting made simple. Contribute to modoboa/modoboa development by creating an account on GitHub.
- 289A system-level, binary package and environment manager running on all major operating systems and platforms.
https://github.com/conda/conda/
A system-level, binary package and environment manager running on all major operating systems and platforms. - conda/conda
- 290Python library for reading audio file metadata
https://github.com/devsnd/tinytag
Python library for reading audio file metadata. Contribute to tinytag/tinytag development by creating an account on GitHub.
- 291Automatically generate a RESTful API service for your legacy database. No code required!
https://github.com/jeffknupp/sandman2
Automatically generate a RESTful API service for your legacy database. No code required! - jeffknupp/sandman2
- 292A Python scikit for building and analyzing recommender systems
https://github.com/NicolasHug/Surprise
A Python scikit for building and analyzing recommender systems - NicolasHug/Surprise
- 293ICU - International Components for Unicode
http://site.icu-project.org/.
News 2024-04-17: ICU 75 is now available. It updates to CLDR 45 (beta blog) locale data with new locales and various additions and corrections. C++ code now requires C++17 and is being made more robust. The CLDR MessageFormat 2.0 specification is now in technology preview, together with a
- 294A computer algebra system written in pure Python
https://github.com/sympy/sympy
A computer algebra system written in pure Python. Contribute to sympy/sympy development by creating an account on GitHub.
- 295WordPress models and views for Django.
https://github.com/istrategylabs/django-wordpress
WordPress models and views for Django. Contribute to jcarbaugh/django-wordpress development by creating an account on GitHub.
- 296Simple and extensible administrative interface framework for Flask
https://github.com/flask-admin/flask-admin
Simple and extensible administrative interface framework for Flask - pallets-eco/flask-admin
- 297Virtual Python Environment builder
https://github.com/pypa/virtualenv
Virtual Python Environment builder. Contribute to pypa/virtualenv development by creating an account on GitHub.
- 298The Python micro framework for building web applications.
https://github.com/pallets/flask
The Python micro framework for building web applications. - pallets/flask
- 299API Documentation for Python Projects
https://github.com/mitmproxy/pdoc
API Documentation for Python Projects. Contribute to mitmproxy/pdoc development by creating an account on GitHub.
- 300Python IMAP for Human beings
https://github.com/martinrusev/imbox
Python IMAP for Human beings. Contribute to martinrusev/imbox development by creating an account on GitHub.
- 301Supervisor process control system for Unix (supervisord)
https://github.com/Supervisor/supervisor
Supervisor process control system for Unix (supervisord) - Supervisor/supervisor
- 302ClickHouse Python Driver with native interface support
https://github.com/mymarilyn/clickhouse-driver
ClickHouse Python Driver with native interface support - mymarilyn/clickhouse-driver
- 303Pony Object Relational Mapper
https://github.com/ponyorm/pony/
Pony Object Relational Mapper. Contribute to ponyorm/pony development by creating an account on GitHub.
- 304x86-64 assembler embedded in Python
https://github.com/Maratyszcza/PeachPy
x86-64 assembler embedded in Python. Contribute to Maratyszcza/PeachPy development by creating an account on GitHub.
- 305Incubator for useful bioinformatics code, primarily in Python and R
https://github.com/chapmanb/bcbb
Incubator for useful bioinformatics code, primarily in Python and R - chapmanb/bcbb
- 306A curated list of awesome tools for SQLAlchemy
https://github.com/dahlia/awesome-sqlalchemy
A curated list of awesome tools for SQLAlchemy. Contribute to dahlia/awesome-sqlalchemy development by creating an account on GitHub.
- 307TinyDB is a lightweight document oriented database optimized for your happiness :)
https://github.com/msiemens/tinydb
TinyDB is a lightweight document oriented database optimized for your happiness :) - msiemens/tinydb
- 308Apache Spark - A unified analytics engine for large-scale data processing
https://github.com/apache/spark
Apache Spark - A unified analytics engine for large-scale data processing - apache/spark
- 309Tornado is a Python web framework and asynchronous networking library, originally developed at FriendFeed.
https://github.com/tornadoweb/tornado
Tornado is a Python web framework and asynchronous networking library, originally developed at FriendFeed. - tornadoweb/tornado
- 310Library for building WebSocket servers and clients in Python
https://github.com/aaugustin/websockets
Library for building WebSocket servers and clients in Python - python-websockets/websockets
- 311Cython implementation of Toolz: High performance functional utilities
https://github.com/pytoolz/cytoolz/
Cython implementation of Toolz: High performance functional utilities - pytoolz/cytoolz
- 312A developer-friendly Python library to interact with Apache HBase
https://github.com/python-happybase/happybase
A developer-friendly Python library to interact with Apache HBase - python-happybase/happybase
- 313Per object permissions for Django
https://github.com/django-guardian/django-guardian
Per object permissions for Django. Contribute to django-guardian/django-guardian development by creating an account on GitHub.
- 314Parsing ELF and DWARF in Python
https://github.com/eliben/pyelftools
Parsing ELF and DWARF in Python. Contribute to eliben/pyelftools development by creating an account on GitHub.
- 315A tool used to obfuscate python scripts, bind obfuscated scripts to fixed machine or expire obfuscated scripts.
https://github.com/dashingsoft/pyarmor
A tool used to obfuscate python scripts, bind obfuscated scripts to fixed machine or expire obfuscated scripts. - dashingsoft/pyarmor
- 316Python QR Code image generator
https://github.com/lincolnloop/python-qrcode
Python QR Code image generator. Contribute to lincolnloop/python-qrcode development by creating an account on GitHub.
- 317A pure Python Database Abstraction Layer
https://github.com/web2py/pydal/
A pure Python Database Abstraction Layer. Contribute to web2py/pydal development by creating an account on GitHub.
- 318Use a docx as a jinja2 template
https://github.com/elapouya/python-docx-template
Use a docx as a jinja2 template. Contribute to elapouya/python-docx-template development by creating an account on GitHub.
- 319A Library for Field-aware Factorization Machines
https://github.com/guestwalk/libffm
A Library for Field-aware Factorization Machines. Contribute to ycjuan/libffm development by creating an account on GitHub.
- 320A better Python REPL
https://github.com/jonathanslenders/ptpython
A better Python REPL. Contribute to prompt-toolkit/ptpython development by creating an account on GitHub.
- 321A fancy and practical functional tools
https://github.com/Suor/funcy
A fancy and practical functional tools. Contribute to Suor/funcy development by creating an account on GitHub.
- 322Subprocesses for Humans 2.0.
https://github.com/amitt001/delegator.py
Subprocesses for Humans 2.0. Contribute to amitt001/delegator.py development by creating an account on GitHub.
- 323Emacs Python Development Environment
https://github.com/jorgenschaefer/elpy
Emacs Python Development Environment. Contribute to jorgenschaefer/elpy development by creating an account on GitHub.
- 324Build software better, together
https://github.com/tayllan/awesome-algorithms.
GitHub is where people build software. More than 100 million people use GitHub to discover, fork, and contribute to over 420 million projects.
- 325Computer art based on quadtrees.
https://github.com/fogleman/Quads
Computer art based on quadtrees. Contribute to fogleman/Quads development by creating an account on GitHub.
- 326A toolbar overlay for debugging Flask applications
https://github.com/pallets-eco/flask-debugtoolbar
A toolbar overlay for debugging Flask applications - pallets-eco/flask-debugtoolbar
- 327Karate Club: An API Oriented Open-source Python Framework for Unsupervised Learning on Graphs (CIKM 2020)
https://github.com/benedekrozemberczki/karateclub
Karate Club: An API Oriented Open-source Python Framework for Unsupervised Learning on Graphs (CIKM 2020) - benedekrozemberczki/karateclub
- 328More routines for operating on iterables, beyond itertools
https://github.com/erikrose/more-itertools
More routines for operating on iterables, beyond itertools - more-itertools/more-itertools
- 329Python GUIs for Humans! PySimpleGUI is the top-rated Python application development environment. Launched in 2018 and actively developed, maintained, and supported in 2024. Transforms tkinter, Qt, WxPython, and Remi into a simple, intuitive, and fun experience for both hobbyists and expert users.
https://github.com/PySimpleGUI/PySimpleGUI
Python GUIs for Humans! PySimpleGUI is the top-rated Python application development environment. Launched in 2018 and actively developed, maintained, and supported in 2024. Transforms tkinter, Qt, ...
- 330Prefect is a workflow orchestration framework for building resilient data pipelines in Python.
https://github.com/PrefectHQ/prefect
Prefect is a workflow orchestration framework for building resilient data pipelines in Python. - PrefectHQ/prefect
- 331RPyC (Remote Python Call) - A transparent and symmetric RPC library for python
https://github.com/tomerfiliba/rpyc
RPyC (Remote Python Call) - A transparent and symmetric RPC library for python - tomerfiliba-org/rpyc
- 332A pure-python PDF library capable of splitting, merging, cropping, and transforming the pages of PDF files
https://github.com/mstamy2/PyPDF2
A pure-python PDF library capable of splitting, merging, cropping, and transforming the pages of PDF files - py-pdf/pypdf
- 333Models | Django documentation
https://docs.djangoproject.com/en/dev/topics/db/models/
The web framework for perfectionists with deadlines.
- 334Build Web Services with Pyramid.
https://github.com/Cornices/cornice
Build Web Services with Pyramid. Contribute to Cornices/cornice development by creating an account on GitHub.
- 335Deduplicating archiver with compression and authenticated encryption.
https://github.com/borgbackup/borg
Deduplicating archiver with compression and authenticated encryption. - borgbackup/borg
- 336Theano was a Python library that allows you to define, optimize, and evaluate mathematical expressions involving multi-dimensional arrays efficiently. It is being continued as PyTensor: www.github.com/pymc-devs/pytensor
https://github.com/Theano/Theano
Theano was a Python library that allows you to define, optimize, and evaluate mathematical expressions involving multi-dimensional arrays efficiently. It is being continued as PyTensor: www.github....
- 337An implementation of Python in Common Lisp
https://github.com/metawilm/cl-python
An implementation of Python in Common Lisp. Contribute to metawilm/cl-python development by creating an account on GitHub.
- 338lightweight python wrapper for vowpal wabbit
https://github.com/josephreisinger/vowpal_porpoise
lightweight python wrapper for vowpal wabbit. Contribute to josephreisinger/vowpal_porpoise development by creating an account on GitHub.
- 339Integration of IPython pdb
https://github.com/gotcha/ipdb
Integration of IPython pdb. Contribute to gotcha/ipdb development by creating an account on GitHub.
- 340Main repository for Vispy
https://github.com/vispy/vispy
Main repository for Vispy. Contribute to vispy/vispy development by creating an account on GitHub.
- 341Python datetimes made easy
https://github.com/sdispater/pendulum
Python datetimes made easy. Contribute to sdispater/pendulum development by creating an account on GitHub.
- 342Web APIs for Django. 🎸
https://github.com/encode/django-rest-framework
Web APIs for Django. 🎸. Contribute to encode/django-rest-framework development by creating an account on GitHub.
- 343local pypi server (custom packages and auto-mirroring of pypi)
https://github.com/jazzband/localshop
local pypi server (custom packages and auto-mirroring of pypi) - mvantellingen/localshop
- 344The Python Package Index
https://github.com/pypa/warehouse
The Python Package Index. Contribute to pypi/warehouse development by creating an account on GitHub.
- 345A functional standard library for Python.
https://github.com/pytoolz/toolz
A functional standard library for Python. Contribute to pytoolz/toolz development by creating an account on GitHub.
- 346A toolkit for developing and comparing reinforcement learning algorithms.
https://github.com/openai/gym
A toolkit for developing and comparing reinforcement learning algorithms. - openai/gym
- 347Cartopy - a cartographic python library with matplotlib support
https://github.com/SciTools/cartopy
Cartopy - a cartographic python library with matplotlib support - SciTools/cartopy
- 348a python refactoring library
https://github.com/python-rope/rope
a python refactoring library. Contribute to python-rope/rope development by creating an account on GitHub.
- 349Python process launching
https://github.com/amoffat/sh
Python process launching. Contribute to amoffat/sh development by creating an account on GitHub.
- 350Statistical data visualization in Python
https://github.com/mwaskom/seaborn
Statistical data visualization in Python. Contribute to mwaskom/seaborn development by creating an account on GitHub.
- 351Fast data visualization and GUI tools for scientific / engineering applications
https://github.com/pyqtgraph/pyqtgraph
Fast data visualization and GUI tools for scientific / engineering applications - pyqtgraph/pyqtgraph
- 352Create Open XML PowerPoint documents in Python
https://github.com/scanny/python-pptx
Create Open XML PowerPoint documents in Python. Contribute to scanny/python-pptx development by creating an account on GitHub.
- 353Declarative User Interfaces for Python
https://github.com/nucleic/enaml
Declarative User Interfaces for Python. Contribute to nucleic/enaml development by creating an account on GitHub.
- 354Numenta Platform for Intelligent Computing is an implementation of Hierarchical Temporal Memory (HTM), a theory of intelligence based strictly on the neuroscience of the neocortex.
https://github.com/numenta/nupic
Numenta Platform for Intelligent Computing is an implementation of Hierarchical Temporal Memory (HTM), a theory of intelligence based strictly on the neuroscience of the neocortex. - numenta/nupic-...
- 355A Python utility / library to sort imports.
https://github.com/timothycrosley/isort
A Python utility / library to sort imports. Contribute to PyCQA/isort development by creating an account on GitHub.
- 356Run Python in Apache Storm topologies. Pythonic API, CLI tooling, and a topology DSL.
https://github.com/Parsely/streamparse
Run Python in Apache Storm topologies. Pythonic API, CLI tooling, and a topology DSL. - pystorm/streamparse
- 357Declarative statistical visualization library for Python
https://github.com/altair-viz/altair
Declarative statistical visualization library for Python - vega/altair
- 358Crontab jobs management in Python
https://github.com/fengsp/plan
Crontab jobs management in Python. Contribute to fengsp/plan development by creating an account on GitHub.
- 359A calendaring app for Django. It is now stable, Please feel free to use it now. Active development has been taken over by bartekgorny.
https://github.com/thauber/django-schedule
A calendaring app for Django. It is now stable, Please feel free to use it now. Active development has been taken over by bartekgorny. - thauber/django-schedule
- 360A Python Object-Document-Mapper for working with MongoDB
https://github.com/MongoEngine/mongoengine
A Python Object-Document-Mapper for working with MongoDB - MongoEngine/mongoengine
- 361Build software better, together
https://github.com/timofurrer/awesome-asyncio.
GitHub is where people build software. More than 100 million people use GitHub to discover, fork, and contribute to over 420 million projects.
- 362New generation PostgreSQL database adapter for the Python programming language
https://github.com/psycopg/psycopg
New generation PostgreSQL database adapter for the Python programming language - GitHub - psycopg/psycopg: New generation PostgreSQL database adapter for the Python programming language
- 363Build software better, together
https://github.com/realpython/list-of-python-api-wrappers.
GitHub is where people build software. More than 100 million people use GitHub to discover, fork, and contribute to over 420 million projects.
- 364Python Imaging Library (Fork)
https://github.com/python-pillow/Pillow
Python Imaging Library (Fork). Contribute to python-pillow/Pillow development by creating an account on GitHub.
- 365Stream Framework is a Python library, which allows you to build news feed, activity streams and notification systems using Cassandra and/or Redis. The authors of Stream-Framework also provide a cloud service for feed technology:
https://github.com/tschellenbach/Stream-Framework
Stream Framework is a Python library, which allows you to build news feed, activity streams and notification systems using Cassandra and/or Redis. The authors of Stream-Framework also provide a clo...
- 366thumbor is an open-source photo thumbnail service by globo.com
https://github.com/thumbor/thumbor
thumbor is an open-source photo thumbnail service by globo.com - thumbor/thumbor
- 367REST API framework designed for human beings
https://github.com/pyeve/eve
REST API framework designed for human beings. Contribute to pyeve/eve development by creating an account on GitHub.
- 368Scalable, Portable and Distributed Gradient Boosting (GBDT, GBRT or GBM) Library, for Python, R, Java, Scala, C++ and more. Runs on single machine, Hadoop, Spark, Dask, Flink and DataFlow
https://github.com/dmlc/xgboost
Scalable, Portable and Distributed Gradient Boosting (GBDT, GBRT or GBM) Library, for Python, R, Java, Scala, C++ and more. Runs on single machine, Hadoop, Spark, Dask, Flink and DataFlow - dmlc/x...
- 369Official upstream for the cloud-init: cloud instance initialization
https://github.com/canonical/cloud-init
Official upstream for the cloud-init: cloud instance initialization - canonical/cloud-init
- 370create custom test databases that are populated with fake data
https://github.com/emirozer/fake2db
create custom test databases that are populated with fake data - emirozer/fake2db
- 371Fixes mojibake and other glitches in Unicode text, after the fact.
https://github.com/LuminosoInsight/python-ftfy
Fixes mojibake and other glitches in Unicode text, after the fact. - rspeer/python-ftfy
- 372Vowpal Wabbit is a machine learning system which pushes the frontier of machine learning with techniques such as online, hashing, allreduce, reductions, learning2search, active, and interactive learning.
https://github.com/JohnLangford/vowpal_wabbit/.
Vowpal Wabbit is a machine learning system which pushes the frontier of machine learning with techniques such as online, hashing, allreduce, reductions, learning2search, active, and interactive lea...
- 373Software to automate the management and configuration of any infrastructure or application at scale. Get access to the Salt software package repository here:
https://github.com/saltstack/salt
Software to automate the management and configuration of any infrastructure or application at scale. Get access to the Salt software package repository here: - GitHub - saltstack/salt: Software to...
- 374Plotting library for IPython/Jupyter notebooks
https://github.com/bloomberg/bqplot
Plotting library for IPython/Jupyter notebooks. Contribute to bqplot/bqplot development by creating an account on GitHub.
- 375Python interface to Graphviz graph drawing package
https://github.com/pygraphviz/pygraphviz/
Python interface to Graphviz graph drawing package - pygraphviz/pygraphviz
- 376🔩 Like builtins, but boltons. 250+ constructs, recipes, and snippets which extend (and rely on nothing but) the Python standard library. Nothing like Michael Bolton.
https://github.com/mahmoud/boltons
🔩 Like builtins, but boltons. 250+ constructs, recipes, and snippets which extend (and rely on nothing but) the Python standard library. Nothing like Michael Bolton. - mahmoud/boltons
- 377Selenium
http://www.seleniumhq.org/
Selenium automates browsers. That's it! What you do with that power is entirely up to you. Primarily it is for automating web applications for testing purposes, but is certainly not limited to just that. Boring web-based administration tasks can (and should) also be automated as well. Getting Started Selenium WebDriver Selenium WebDriver If you want to create robust, browser-based regression automation suites and tests, scale and distribute scripts across many environments, then you want to use Selenium WebDriver, a collection of language specific bindings to drive a browser - the way it is meant to be driven.
- 378Machine learning evaluation metrics, implemented in Python, R, Haskell, and MATLAB / Octave
https://github.com/benhamner/Metrics
Machine learning evaluation metrics, implemented in Python, R, Haskell, and MATLAB / Octave - benhamner/Metrics
- 379DataStax Python Driver for Apache Cassandra
https://github.com/datastax/python-driver
DataStax Python Driver for Apache Cassandra. Contribute to datastax/python-driver development by creating an account on GitHub.
- 380A configurable set of panels that display various debug information about the current request/response.
https://github.com/jazzband/django-debug-toolbar
A configurable set of panels that display various debug information about the current request/response. - jazzband/django-debug-toolbar
- 381Creating delicious APIs for Django apps since 2010.
https://github.com/django-tastypie/django-tastypie
Creating delicious APIs for Django apps since 2010. - django-tastypie/django-tastypie
- 382A Grammar of Graphics for Python
https://github.com/has2k1/plotnine
A Grammar of Graphics for Python. Contribute to has2k1/plotnine development by creating an account on GitHub.
- 383The platform for building AI from enterprise data
https://github.com/mindsdb/mindsdb
The platform for building AI from enterprise data. Contribute to mindsdb/mindsdb development by creating an account on GitHub.
- 384A curated list of awesome Jupyter projects, libraries and resources
https://github.com/markusschanta/awesome-jupyter
A curated list of awesome Jupyter projects, libraries and resources - markusschanta/awesome-jupyter
- 385Useful extensions to the standard Python datetime features
https://github.com/dateutil/dateutil
Useful extensions to the standard Python datetime features - dateutil/dateutil
- 386Debugging manhole for python applications.
https://github.com/ionelmc/python-manhole
Debugging manhole for python applications. Contribute to ionelmc/python-manhole development by creating an account on GitHub.
- 387The comprehensive WSGI web application library.
https://github.com/pallets/werkzeug
The comprehensive WSGI web application library. Contribute to pallets/werkzeug development by creating an account on GitHub.
- 388A little Python library for making simple Electron-like HTML/JS GUI apps
https://github.com/ChrisKnott/Eel
A little Python library for making simple Electron-like HTML/JS GUI apps - python-eel/Eel
- 389Python flexible slugify function
https://github.com/dimka665/awesome-slugify
Python flexible slugify function. Contribute to voronind/awesome-slugify development by creating an account on GitHub.
- 390Bayesian Modeling and Probabilistic Programming in Python
https://github.com/pymc-devs/pymc3
Bayesian Modeling and Probabilistic Programming in Python - pymc-devs/pymc
- 391A set of tools to keep your pinned Python dependencies fresh.
https://github.com/jazzband/pip-tools
A set of tools to keep your pinned Python dependencies fresh. - jazzband/pip-tools
- 392Browsable web APIs for Flask.
https://github.com/flask-api/flask-api
Browsable web APIs for Flask. Contribute to flask-api/flask-api development by creating an account on GitHub.
- 393The official Python SDK for Sentry.io
https://github.com/getsentry/sentry-python
The official Python SDK for Sentry.io. Contribute to getsentry/sentry-python development by creating an account on GitHub.
- 394Remote task execution tool
https://github.com/gunnery/gunnery
Remote task execution tool. Contribute to gunnery/gunnery development by creating an account on GitHub.
- 395Statsmodels: statistical modeling and econometrics in Python
https://github.com/statsmodels/statsmodels
Statsmodels: statistical modeling and econometrics in Python - statsmodels/statsmodels
- 396pyinfra turns Python code into shell commands and runs them on your servers. Execute ad-hoc commands and write declarative operations. Target SSH servers, local machine and Docker containers. Fast and scales from one server to thousands.
https://github.com/pyinfra-dev/pyinfra
pyinfra turns Python code into shell commands and runs them on your servers. Execute ad-hoc commands and write declarative operations. Target SSH servers, local machine and Docker containers. Fast ...
- 397Interactive Data Visualization in the browser, from Python
https://github.com/bokeh/bokeh
Interactive Data Visualization in the browser, from Python - bokeh/bokeh
- 398Send email in Python conveniently for gmail using yagmail
https://github.com/kootenpv/yagmail
Send email in Python conveniently for gmail using yagmail - kootenpv/yagmail
- 399A fast Python in-process signal/event dispatching system.
https://github.com/jek/blinker
A fast Python in-process signal/event dispatching system. - pallets-eco/blinker
- 400🐍 The official Python client library for Google's discovery based APIs.
https://github.com/google/google-api-python-client
🐍 The official Python client library for Google's discovery based APIs. - googleapis/google-api-python-client
- 401📐 Compute distance between sequences. 30+ algorithms, pure python implementation, common interface, optional external libs usage.
https://github.com/orsinium/textdistance
📐 Compute distance between sequences. 30+ algorithms, pure python implementation, common interface, optional external libs usage. - life4/textdistance
Queriesor most google FAQ's about Python.
mail [email protected] to add more queries here 🔍.
- 1
how does python programming work
- 2
which app is best for python programming
- 3
what python programming can do
- 4
when was python programming language created
- 5
how long will it take to learn python programming
- 6
how to learn python programming for free
- 7
what can we do with python programming language
- 8
is python programming useful
- 9
why python programming is used
- 10
what are python programming language
- 11
what python programming language
- 12
why python programming is awesome
- 13
how to do python programming in mobile
- 14
why python programming language
- 15
which type of programming does python support
- 16
is python programming hard
- 17
is python coding free
- 18
where is python coding used
- 19
what does python programming look like
- 20
what are some limitations of python programming language
- 21
how to do python programming in jupyter notebook
- 22
is python programming language easy to learn
- 23
how to do python programming in vs code
- 24
is python programming hard to learn
- 25
which laptop is best for python programming
- 26
how to do python programming
- 27
which book is best for python programming
- 28
will python 4 come out
- 29
how to use anaconda for python programming
- 30
what can you do with python programming
- 31
what are the basics of python programming
- 32
how will i learn atl skills with python programming
- 33
what are variables in python programming
- 34
is python programming or scripting
- 35
why learn python programming
- 36
how long has python programming been around
- 37
where is python used and why
- 38
how to do python programming in laptop
- 39
what can you do with python programming language
- 40
what programming language should i learn after python
- 41
what has python been used for
- 42
is python sequential programming
- 43
who is the best python programmer in the world
- 44
how long does it take to learn python programming
- 45
can i do python programming on ipad
- 46
when is python used
- 47
is python programming easy to learn
- 48
who developed python programming language
- 49
where to start python programming
- 50
why python programming language named python
- 51
what are the uses of python programming
- 52
why python programming is important
- 53
which programming language is used in python
- 54
where python programming language is used
- 55
what are the good python programming practices
- 56
- 57
how is python different from other programming languages
- 58
is python named after monty python
- 59
is python the easiest programming language
- 60
is python programming in demand
- 61
why was python developed
- 62
will python die
- 63
why was python programming language created
- 64
does python support functional programming
- 65
where to learn python programming for free
- 66
where to program python
- 67
what are the functions of python programming
- 68
who is the father of python programming language
- 69
is python a programming software
- 70
why you should learn python programming
- 71
what is python as a programming language
- 72
who coded python
- 73
what is socket programming python
- 74
have python point to python3
- 75
can i do competitive programming in python
- 76
how did python programming get its name
- 77
who owns python programming language
- 78
is python programming language or scripting language
- 79
who developed python and when
- 80
what should be considered when using operators in python programming
- 81
why python is important
- 82
what should be used to terminate statements in python programming
- 83
how to make a programming language in python
- 84
where to practice python programming
- 85
how to practice python programming
- 86
why python is the best programming language
- 87
will python be replaced
- 88
who wrote python programming language
- 89
why is python good for beginners
- 90
why python programming is necessary
- 91
does python have object oriented programming
- 92
how long does it take to master python programming
- 93
how to do python programming in computer
- 94
does python support object oriented programming
- 95
what is functional programming in python
- 96
what jobs can you get with python programming
- 97
was python written in c
- 98
what are the features of python programming language
- 99
how would you describe object-oriented programming in python
- 100
who create python programming language
- 101
which app is used for python programming
- 102
who uses python programming language
- 103
what are the applications of python programming
- 104
what can python programming be used for
- 105
when python was created
- 106
who can learn python programming
- 107
where python programming is used
- 108
why was python invented
- 109
should you learn python
- 110
why should we learn python programming
- 111
why python is famous
- 112
will python become obsolete
- 113
what does python programming do
- 114
how python programming language works
- 115
who created python and why
- 116
which software is used for python programming
- 117
why python is most popular programming language
- 118
why python is popular programming language
- 119
how to do python programming for beginners
- 120
is python programming language
- 121
who developed python programming language and when
- 122
what python programming is used for
- 123
why python programming is called python
- 124
how is a function written in python programming language
- 125
is python programming free
- 126
what is object oriented programming in python
- 127
which software is best for python programming
- 128
how does python compare to other programming languages
- 129
what are the advantages of python programming language
- 130
what jobs can i get with python programming
- 131
who is the father of python
- 132
what does python programming mean
- 133
who uses python programming
- 134
what is gui programming in python
- 135
how to programming in python
- 136
is python necessary
- 137
do python programming online
More Sitesto check out once you're finished browsing here.
https://www.0x3d.site/
0x3d is designed for aggregating information.
https://nodejs.0x3d.site/
NodeJS Online Directory
https://cross-platform.0x3d.site/
Cross Platform Online Directory
https://open-source.0x3d.site/
Open Source Online Directory
https://analytics.0x3d.site/
Analytics Online Directory
https://javascript.0x3d.site/
JavaScript Online Directory
https://golang.0x3d.site/
GoLang Online Directory
https://python.0x3d.site/
Python Online Directory
https://swift.0x3d.site/
Swift Online Directory
https://rust.0x3d.site/
Rust Online Directory
https://scala.0x3d.site/
Scala Online Directory
https://ruby.0x3d.site/
Ruby Online Directory
https://clojure.0x3d.site/
Clojure Online Directory
https://elixir.0x3d.site/
Elixir Online Directory
https://elm.0x3d.site/
Elm Online Directory
https://lua.0x3d.site/
Lua Online Directory
https://c-programming.0x3d.site/
C Programming Online Directory
https://cpp-programming.0x3d.site/
C++ Programming Online Directory
https://r-programming.0x3d.site/
R Programming Online Directory
https://perl.0x3d.site/
Perl Online Directory
https://java.0x3d.site/
Java Online Directory
https://kotlin.0x3d.site/
Kotlin Online Directory
https://php.0x3d.site/
PHP Online Directory
https://react.0x3d.site/
React JS Online Directory
https://angular.0x3d.site/
Angular JS Online Directory