Acme-Constructor-Pythonic

 view release on metacpan or  search on metacpan

README  view on Meta::CPAN

NAME
    Acme::Constructor::Pythonic - import Python-style constructor functions

SYNOPSIS
        use Acme::Constructor::Pythonic qw(
            LWP::UserAgent
            JSON
            HTTP::Request
        );
    
        my $json = JSON();
        my $ua   = UserAgent();
        my $req  = Request( GET => 'http://www.example.com/foo.json' );
    
        my $data = $json->decode( $ua->request($req)->content )

DESCRIPTION
    In Python you import classes like this:

        import BankAccount from banking

    And you instantiate them with something looking like a function call:

        acct = BankAccount(9.99)

    This module allows Python-like object instantiation in Perl. The example
    in the SYNOPSIS creates three functions `UserAgent`, `JSON` and <Request>
    each of which just pass through their arguments to the real object
    constructors.

  Options
    Each argument to the Acme::Constructor::Pythonic is a Perl module name and
    may be followed by a hashref of options:

        use Acme::Constructor::Pythonic
            'A::Module',
            'Another::Module' => \%some_options,

lib/Acme/Constructor/Pythonic.pm  view on Meta::CPAN

__END__

=head1 NAME

Acme::Constructor::Pythonic - import Python-style constructor functions

=head1 SYNOPSIS

    use Acme::Constructor::Pythonic qw(
        LWP::UserAgent
        JSON
        HTTP::Request
    );
    
    my $json = JSON();
    my $ua   = UserAgent();
    my $req  = Request( GET => 'http://www.example.com/foo.json' );
    
    my $data = $json->decode( $ua->request($req)->content )

=head1 DESCRIPTION

In Python you import classes like this:

    import BankAccount from banking

And you instantiate them with something looking like a function call:

    acct = BankAccount(9.99)

This module allows Python-like object instantiation in Perl. The example in
the SYNOPSIS creates three functions C<UserAgent>, C<JSON> and <Request> each
of which just pass through their arguments to the real object constructors.

=head2 Options

Each argument to the Acme::Constructor::Pythonic is a Perl module name and
may be followed by a hashref of options:

    use Acme::Constructor::Pythonic
        'A::Module',
        'Another::Module' => \%some_options,



( run in 0.876 second using v1.01-cache-2.11-cpan-cdf2f3d4e48 )