[−][src]Struct pycall::PythonProgram
An instance of code generation unit. It really is just a file with dedicated APIs to write Python into it. Most importantly: it manages indentation for you.
Methods
impl PythonProgram
[src]
ⓘImportant traits for PythonProgrampub fn new() -> PythonProgram
[src]
Creates a named temp file to store the generated python program
pub fn save_as<P: AsRef<Path>>(&self, path: P) -> Result<u64, Error>
[src]
pub fn run(&self) -> Result<Output, Error>
[src]
Runs the program using python3
pub fn background_run(self) -> JoinGuard<Result<Output, Error>>
[src]
Spawns a thread to run the program using python3. The returned JoinGuard ensures that the program will be ran to completion.
pub fn flush(&mut self) -> &mut Self
[src]
Ensures that the internal file has been flushed. Typically not necessary.
pub fn indent(&mut self, n: isize) -> &mut Self
[src]
Moves the indentation level by n
. However, I recommend using the dedicated functions when possible/
pub fn end_block(&mut self) -> &mut Self
[src]
Removes one indentation level from the cursor. You should call this whenever you're done with a scope.
pub fn define_variable<T: AsPythonLitteral + ?Sized>(
&mut self,
name: &str,
value: &T
) -> &mut Self
[src]
&mut self,
name: &str,
value: &T
) -> &mut Self
Writes a line assigning value
formatted as a python literal to name
pub fn import(&mut self, dependency: &str) -> &mut Self
[src]
Writes an import statement for your dependency
pub fn import_as(&mut self, dependency: &str, rename: &str) -> &mut Self
[src]
Writes an import statement for your dependency
as rename
pub fn write_line(&mut self, line: &str) -> &mut Self
[src]
Writes whatever line you passed it, indented at the proper level.
pub fn if(&mut self, condition: &str) -> &mut Self
[src]
Writes an if, using your condition as a test, and increments indentation.
pub fn elif(&mut self, condition: &str) -> &mut Self
[src]
Decrements indentation, writes an elif, using your condition as a test, and increments indentation.
pub fn else(&mut self) -> &mut Self
[src]
Decrements indentation, writes an else, using your condition as a test, and increments indentation.
pub fn for(&mut self, range: &str) -> &mut Self
[src]
Writes "for range
:", and increments indentation.
pub fn while(&mut self, condition: &str) -> &mut Self
[src]
Writes a while, using your condition as a test, and increments indentation.
Trait Implementations
impl Display for PythonProgram
[src]
impl MatPlotLib for PythonProgram
[src]
fn import_pyplot_as_plt(&mut self) -> &mut Self
[src]
fn plot_y<Y: AsPythonLitteral>(&mut self, y: &Y) -> &mut Self
[src]
fn plot_xy<X: AsPythonLitteral, Y: AsPythonLitteral>(
&mut self,
x: &X,
y: &Y
) -> &mut Self
[src]
&mut self,
x: &X,
y: &Y
) -> &mut Self
fn plot_xyargs<X: AsPythonLitteral, Y: AsPythonLitteral>(
&mut self,
x: &X,
y: &Y,
args: &str
) -> &mut Self
[src]
&mut self,
x: &X,
y: &Y,
args: &str
) -> &mut Self
fn semilogy_y<Y: AsPythonLitteral>(&mut self, y: &Y) -> &mut Self
[src]
fn semilogy_xy<X: AsPythonLitteral, Y: AsPythonLitteral>(
&mut self,
x: &X,
y: &Y
) -> &mut Self
[src]
&mut self,
x: &X,
y: &Y
) -> &mut Self
fn semilogy_xyargs<X: AsPythonLitteral, Y: AsPythonLitteral>(
&mut self,
x: &X,
y: &Y,
args: &str
) -> &mut Self
[src]
&mut self,
x: &X,
y: &Y,
args: &str
) -> &mut Self
fn show(&mut self) -> &mut Self
[src]
impl Write for PythonProgram
[src]
fn write(&mut self, buf: &[u8]) -> Result<usize, Error>
[src]
fn flush(&mut self) -> Result<(), Error>
[src]
fn write_vectored(&mut self, bufs: &[IoSlice]) -> Result<usize, Error>
1.36.0[src]
fn write_all(&mut self, buf: &[u8]) -> Result<(), Error>
1.0.0[src]
fn write_fmt(&mut self, fmt: Arguments) -> Result<(), Error>
1.0.0[src]
fn by_ref(&mut self) -> &mut Self
1.0.0[src]
Auto Trait Implementations
impl RefUnwindSafe for PythonProgram
impl Send for PythonProgram
impl Sync for PythonProgram
impl Unpin for PythonProgram
impl UnwindSafe for PythonProgram
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,