コード例 #1
0
import helpers

helpers.display("This is a sample message")

helpers.display("This is a warning message", True)

"""
You can import specific funciton from the module
Besides, if the method is the unique name, you can skip the modeule name
"""
from helpers import display
display("This is a sample message")
display("This is a warning message", True)
コード例 #2
0
ファイル: modules.py プロジェクト: sauravk7077/Python
#import module as namespace
import helpers
helpers.display("It is not a warning")

#import all into current namespace
from helpers import *
display("Not a warning")

#import specific items into current namespace
from helpers import display
display("Not a warning")


import sys

sys.path.append('c:\\Users\\racer\\Documents\\Module')

from some_random_module import do_something_stupid as stupid
stupid(5)
コード例 #3
0
# -*- coding: utf-8 -*-
"""
Created on Sat Sep 26 14:19:01 2020

@author: daxiguammm
"""

#Modules
#What's the modules?
#A python file with functions ,classes and other components
#Why use the modules?
#Break code doun into reusable structures

#Import a mudule

#fucntion 1
#import module as namespace
import helpers
helpers.display('Not a worning')

#function 2
#import all into current namespace
from helpers import *
display('Not a worning')

#function 3
#import specific items into current namespace
from helpers import display
display('Not a worning')
コード例 #4
0
# module is a python file with functions,classes and other components

#why use modules as it breaks code down and make code reusable

#create a module


def display(message, is_warning=False):
    if is_warning:
        print('Warning!!')
    print(message)


# import module as namespace
import helpers
helpers.display('Not a warning')

# import all into current namespace
from helpers import *
display('Not a Warning!!')

# import specific items into urrent namespace
from helpers import display
display('Not a warning')

# packages are published collections of modules can be found python package index
# pip install colorama

# virtual environments
# by default packages are installed globbally
# Due to this version management beomes a  challenge
コード例 #5
0
import helpers
from sklearn.cluster import KMeans

num_clusters, original_labels, points = helpers.generate_data_points()

helpers.display(points, original_labels)

(centers, labels, it) = helpers.kmeans(points, num_clusters)
print('Centers found by algorithm: ')
print(centers)
print('Total iterations: {}'.format(it))

helpers.display(points, labels)

kmeans = KMeans(n_clusters=3, random_state=0).fit(points)
print('Centers found by scikit-learn library: ')
print(kmeans.cluster_centers_)
pred_label = kmeans.predict(points)
print('Total iterations using scikit-learn library: {}'.format(kmeans.n_iter_))

helpers.display(points, pred_label)
コード例 #6
0
def print_python_ver():
    helpers.display("Python version=" + str(sys.version) + ", version info=" + str(sys.version_info))
コード例 #7
0
# import module as namespace
import helpers
helpers.display('Sample Message', True)

# import all into current namespace
from helpers import *
display('Not a warning')

# import specific items into current namespace
from helpers import display
display('Not a warning')
コード例 #8
0
#Import everything from the module
import helpers
helpers.display('Sample message', True)
#Only import the display function
from helpers import display
display('Sample message')
コード例 #9
0
import helpers
helpers.display('sample message', True)
コード例 #10
0
# -*- coding: utf-8 -*-
"""
Created on Sat Sep 26 14:57:57 2020

@author: daxiguammm
"""

import helpers
helpers.display('Sample message', True)
print('\n')

from helpers import *
display('hello word', False)

from helpers import display
display('Sample message', True)

#Virtual environments
コード例 #11
0
ファイル: demo.py プロジェクト: a2zazure/mypythoncodes
import helpers
helpers.display('Simple Message', True)
print()
helpers.display('Simple Message All. \n this is new', False)
コード例 #12
0
# the force_uppercase defaults to False
# first_name_initial = get_initial(first_name)
# first_name_initial = get_initial(first_name, False)
# the following makes the code more readible by using named parameters
# first_name_initial = get_initial(force_uppercase = False, name = first_name)

# print('Your name initials are: ' + first_name_initial)

# MODULES, PUBLISHED COLECTION OF MODULES CALLED PACKAGES ('Python Package Index' on the internet)
# import a module as namespace
# import helpers
# helpers.display('Not a warning!!')

# # import all into current namespace
from helpers import display
display('Not a warning!!', True)

#import specific item(s) into current namespace
from helpers import display
display('Not a warning!!')

# # INSTALLING PACKAGES
# #install an individual package
# pip install colorama

# #install from a list of packages
# pip install -r requirements.txt

# # requirements.txt
# colorama
コード例 #13
0
from helpers import display

display('Sample message')
display('Sample message', True)
コード例 #14
0
#!/usr/bin/env python3

## Import module as namesapce
import helpers

helper.display('Not a warning')

## Import all into current namespace
from helpers import *

display('Not a warning')

## Import specific items into current namespace
from helpers import display

display('Not a warning')
コード例 #15
0
# otherfile.py
# we can import file 3 type

# import specific items into current namespace
from helpers import display

# import all into current namespace
# * means all
from helpers import *

# import module as namespace
import helpers

helpers.display('Not a Warning')

display('Not a Warning', True)

display('Not a Warning')
コード例 #16
0
ファイル: demo.py プロジェクト: arridha-amrad/python_and_ML
from helpers import display

display("sample message", warning=False)
# 35. and 36. lesson - VE packages
import helpers
#helpers.display("Sample message", True)

# When we add True - This is a warning is printed out

# To make display available always -> output is the same
from helpers import display

display("Sample message")

# # Setting a virtual environment = our own module
# # Installing a package into there - virtualenv <folder_name>
# # https://docs.python.org/3/tutorial/venv.html

# # Create environment
# python3 -m venv tutorial-env
# # Activate - I will see ('tutorial-env':venv)
# source tutorial-env/bin/activate

# ? pip install --upgrade pip
# python3 -m pip install --user --upgrade pip

# # Installs colorama (external package) once
# pip install colorama
# # Installs colorama permanently - I need to create requirements.txt
# pip install -r requirements.txt
コード例 #18
0
import helpers
helpers.display("This is a sample message", True)

# if you  wanted to import everything you would do the following
from helpers import *
# then use the same print as above
helpers.display("This is a sample message")

# However, if I only wanted to import one function
# I would do this
from helpers import display
display("This is another sample message")
コード例 #19
0
ファイル: use_helpers.py プロジェクト: VannucciS/msLessons
import helpers

helpers.display('Not a warning!', True)
コード例 #20
0
ファイル: demos.py プロジェクト: gmmann/MSPythonCourse
import helpers
helpers.display('Sample message', True)



from helpers import display
display('Sample message', True)

display('Another message', False)
display('Happy Birthday!!!')
コード例 #21
0
# -*- coding: utf-8 -*-
"""
Created on Fri Aug 21 13:44:58 2020

@author: aduzo
"""

# To use a module,
# import module as namespace
# this code pulled in all of the functions and made it available
# inside a little collection, or inside what is known as a namespace
import helpers  # the name of the python file we created
helpers.display('Sample message',
                True)  # there is a display function inside it

# from module helpers, I want to import everything.
# Everything in  this module will become globally available
# import all into current namespace
from helpers import *
display('Not a warning')

# Just grab one item
#import specific item into current namespace
from helpers import display
display('Not a warning')
'''
It is best to import only items you need else you will see
more suggestions from your intelliscence
'''
'''
コード例 #22
0
        new_board = assign_value(new_board, easiest_square_coor, possible_value)
        possible_solution = search(new_board)
        if possible_solution:
            return possible_solution

def solve(grid):
    """
    Find the solution to a Sudoku grid.
    Args:
        grid(string): a string representing a sudoku grid.
            Example: '2.............62....1....7...6..8...3...9...7...6..4...4....8....52.............3'
    Returns:
        The dictionary representation of the final sudoku grid. False if no solution exists.
    """
    dict_board = grid_values(grid)
    return search(dict_board)


if __name__ == '__main__':
    diag_sudoku_grid = '2.............62....1....7...6..8...3...9...7...6..4...4....8....52.............3'
    display(solve(diag_sudoku_grid))

    try:
        from visualize import visualize_assignments
        visualize_assignments(assignments)

    except SystemExit:
        pass
    except:
        print('We could not visualize your board due to a pygame issue. Not a problem! It is not a requirement.')
コード例 #23
0
# namespace import
from helpers import display


# Testing Helpers
display('I am Tin not Warning')
display('I am Kaitod', True)
コード例 #24
0
import helpers
helpers.display("Sample message", True)

from helpers import *
display("Sample message", True)

from helpers import display
display("Sample message", True)
コード例 #25
0
import helpers
from helpers import display

helpers.display("sample message", True)
display("sample message", False)
コード例 #26
0
ファイル: demos.py プロジェクト: grimb300/ms_python_tutorials
import helpers
helpers.display('Sample message', is_warning=True)

from helpers import display
display('Sample message too')
コード例 #27
0
# import module as namespace
import helpers
helpers.display('Sample message')

# import all into current namespace
from helpers import *
display('Not a warning')

# import specific items into current namespace
from helpers import display
display('Not a warning')