Sponsored Content
Full Discussion: Simple Python Code Question
Top Forums Shell Programming and Scripting Simple Python Code Question Post 303018027 by wisecracker on Sunday 27th of May 2018 05:50:53 AM
Old 05-27-2018
Hi skysmart...

I have no idea what you are trying to do but your function is not called.
I guess you are trying to put that function in the interpreter namespace for other uses.

The function has a useless line and looks as though you want Python version 2.x.x and the print STATEMENT.
If you require version 3.x.x then you need the print FUNCTION and the end=" " _flag_.
Code:
#!/usr/bin/python2.7
mylist = [ "hello", "you", "are", "so", "cool" ]

def printWithoutNewlines():
    for objects in mylist:
        objects = objects.replace('hello', "hi")
        # Note the comma below.
        print objects ,

printWithoutNewlines()

OSX 10.13.4, default bash terminal calling python2.7.
Code:
Last login: Sun May 27 10:36:33 on ttys000
AMIGA:barrywalker~> cd Desktop/Code/Python
AMIGA:barrywalker~/Desktop/Code/Python> chmod 755 loop.py
AMIGA:barrywalker~/Desktop/Code/Python> ./loop.py
hi you are so cool
AMIGA:barrywalker~/Desktop/Code/Python> _


Last edited by wisecracker; 05-27-2018 at 06:57 AM..
This User Gave Thanks to wisecracker For This Post:
 

7 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Ok simple question for simple knowledge...

Ok what is BSD exactly? I know its a type of open source but what is it exactly? (1 Reply)
Discussion started by: Corrail
1 Replies

2. Red Hat

Writing simple python setup commands

Building software in most languages is a pain. Remember ant build.xml, maven2 pom files, and multi-level makefiles? Python has a simple solution for building modules, applications, and extensions called distutils. Disutils comes as part of the Python distribution so there are no other packages... (0 Replies)
Discussion started by: Linux Bot
0 Replies

3. Shell Programming and Scripting

Help with Simple Perl/Python Script

I have the following problem, which I need done in Perl/ or Python using Unix/linux filters... 1. You have a very large file, named 'ColCheckMe', tab-delmited, that you are asked to process. You are told that each line in 'ColCheckMe' has 7 columns, and that the values in the... (1 Reply)
Discussion started by: Swapnilsagarwal
1 Replies

4. Homework & Coursework Questions

Help with Simple Perl/Python Script

I have the following problem, which I need done in Perl/ or Python using Unix/linux filters... 1. You have a very large file, named 'ColCheckMe', tab-delmited, that you are asked to process. You are told that each line in 'ColCheckMe' has 7 columns, and that the values... (1 Reply)
Discussion started by: Swapnilsagarwal
1 Replies

5. Programming

Simple encryption in python

Hi, i have the below script: ###############################SimpleEncryption################################ #Simple encryption implemented in python #Author:pandeeswaran ############################################################################### def Encrypt(input): res='' ... (13 Replies)
Discussion started by: pandeesh
13 Replies

6. Red Hat

Syslog.conf: looking for a simple answer on a simple question

Cheers! In /etc/syslog.conf, if an error type is not specified, is it logged anywhere (most preferable is it logged to /var/log/messages) or not? To be more precise I am interested in error and critical level messages. At default these errors are not specified in syslog.conf, and I need to... (6 Replies)
Discussion started by: dr1zzt3r
6 Replies

7. OS X (Apple)

Python script to do simple audio capture...

This site is the first to get this snippet. It will capture an audio recording of any time length within the limits of OSX's QuickTime Player's capablility... A shell script derivative of this will be used as a further capture for CygWin's AudioScope.sh. Thoroughly read ALL the comments in... (0 Replies)
Discussion started by: wisecracker
0 Replies
CYTHON(1)							   User Commands							 CYTHON(1)

NAME
Cython - compile Cython code (.pyx) into C to build a Python extension SYNOPSIS
cython [options] sourcefile.{pyx,py} ... DESCRIPTION
Cython (http://cython.org) is a compiler for code written in the Cython language. Cython is based on Pyrex by Greg Ewing. OPTIONS
-V, --version Display version number of cython compiler -l, --create-listing Write error messages to a listing file -I, --include-dir <directory> Search for include files in named directory (multiple include directories are allowed). -o, --output-file <filename> Specify name of generated C file -t, --timestamps Only compile newer source files -f, --force Compile all source files (overrides implied -t) -q, --quiet Don't print module names in recursive mode -v, --verbose Be verbose, print file names on multiple compilation -p, --embed-positions If specified, the positions in Cython files of each function definition is embedded in its docstring. --cleanup <level> Release interned objects on python exit, for memory debugging. Level indicates aggressiveness, default 0 releases nothing. -w, --working <directory> Sets the working directory for Cython (the directory modules are searched from) --gdb Output debug information for cygdb -D, --no-docstrings Strip docstrings from the compiled module. -a, --annotate Produce a colorized HTML version of the source. --line-directives Produce #line directives pointing to the .pyx source --cplus Output a C++ rather than C file. --embed[=<method_name>] Generate a main() function that embeds the Python interpreter. -2 Compile based on Python-2 syntax and code semantics. -3 Compile based on Python-3 syntax and code semantics. --fast-fail Abort the compilation on the first error --warning-error, -Werror Make all warnings into errors --warning-extra, -Wextra Enable extra warnings -X, --directive <name>=<value>[,<name=value,...] Overrides a compiler directive Cython version 0.15.1 January 2012 CYTHON(1)
All times are GMT -4. The time now is 01:51 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy