Korea Polytechnic University Graduation Works Team Repository

Sanki University graduation work team repository

url : http://sehwan96.com.s3-website.ap-northeast-2.amazonaws.com/

  • Directory organization
/
front_codes
    - react-app
    README.md
backend_codes
    - platfrom code
    REAMDE.md
test_codes
    - 테스트 디렉터리들
  • In the master branch, each branch works.
  • Branch convention: {contents}/{parts}/{details}
  • There are a total of 4 contents. feature, bugfix, hotfix, enhancement
  • 예제 : feature/front/add-react-app
  • 예제 : feature/back/fix-aws-resources
  • When your work is done, push to your branch and write a PR.
git branch feature/back/fix-aws-resources
git checkout feature/back/fix-aws-resources
git pull origin master --rebase
- 본인의 작업 실시 -
- 완료 되었을 경우-
git add *
git commit -m "add some validation logic"
git push origin feature/back/fix-aws-resources
- 이후 깃헙에 들어가서 PR 작성 및 리뷰 리퀘스트 -
  • Receive a review from the team leader (Kim Se-hwan) and merge the PR.

distribute

  • The front code is automatically deployed and deployed using the github action. (Whenever a push event occurs on the master branch, it is uploaded to the S3 bucket)
name : React build 
on : 
   push :                                ## Run only when a push event occurs in the master branch 
    branches :
      - master

jobs:
  build:
    runs-on: ubuntu-18.04
    steps:
      - name The : Checkout, the Source code.   ## Check out repository 
        uses : actions/checkout@master

      - name: Cache node modules      ## node modules 캐싱
        uses: actions/cache@v1
        with:
          path: front_codes/my-app/node_modules
          key: ${{ runner.OS }}-build-${{ hashFiles('**/package-lock.json') }}
          restore-keys: |
            ${{ runner.OS }}-build-
            ${{ runner.OS }}-

      - name: Display the path
        run: pwd && ls

      - name The : the Change Directory ## directory, moving 
        the Run : the CD front_codes / My-the App

      - name The : the Install the Dependencies     ## dependent files installed 
        the Run : the CD front_codes / My-npm the install the App &&

      - name: Build                   ## React Build
        run: cd front_codes/my-app && npm run build

      - name: Deploy                  ## S3에 배포하기
        env:
          AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
          AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
        run: |
          aws s3 cp \
            --recursive \
            --region ap-northeast-2 \
            front_codes/my-app/build s3://sehwan96.com ## 

Skill stack used

  1. AWS
  • DynamoDB
  • RDS(Postgresql)
  • Lambda
  • GreenGrass
  • Appsync
  • GraphQL
  • Amplify
  • S3
  • CloudWatch
  1. Front
  • React.js
  • Material UI
  • D3.js
  • webpack
  • yarn
  • above sea level
  1. DevOps
  • Jenkins
  • Serverless(with AWS)
  • Docker(Greengrass Deploy)

Google Python Coding-Style Translation (Translator Se-Hwan Kim)

Original: https://google.github.io/styleguide/pyguide.html

1 Background

Python is a very active main language language at Google. This style guide has listed do’s and don’ts for coding Python.

To make coding auto-formatting accurate, I created a setting file for Vim (for Vim users).

" Copyright 2019 Google LLC
"
" Licensed under the Apache License, Version 2.0 (the "License");
" you may not use this file except in compliance with the License.
" You may obtain a copy of the License at
"
"    https://www.apache.org/licenses/LICENSE-2.0
"
" Unless required by applicable law or agreed to in writing, software
" distributed under the License is distributed on an "AS IS" BASIS,
" WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
" See the License for the specific language governing permissions and
" limitations under the License.

" Indent Python in the Google way.

setlocal indentexpr=GetGooglePythonIndent(v:lnum)

let s:maxoff = 50 " maximum number of lines to look backwards.

function GetGooglePythonIndent(lnum)

  " Indent inside parens.
  " Align with the open paren unless it is at the end of the line.
  " E.g.
  "   open_paren_not_at_EOL(100,
  "                         (200,
  "                          300),
  "                         400)
  "   open_paren_at_EOL(
  "       100, 200, 300, 400)
  call cursor(a:lnum, 1)
  let [par_line, par_col] = searchpairpos('(\|{\|\[', '', ')\|}\|\]', 'bW',
        \ "line('.') < " . (a:lnum - s:maxoff) . " ? dummy :"
        \ . " synIDattr(synID(line('.'), col('.'), 1), 'name')"
        \ . " =~ '\\(Comment\\|String\\)$'")
  if par_line > 0
    call cursor(par_line, 1)
    ifpar_col ! =  col ( " $ " ) -  1 
      return par_col
     endif 
  endif

  " Delegate the rest to the original function.
  return GetPythonIndent(a:lnum)

endfunction

let pyindent_nested_paren="&sw*2"
let pyindent_open_paren="&sw*2"

(We won’t write)

2 Python rules

2.2 Imports

import The syntax is not used to import each class or function,

Justice

It is a reusable mechanism for sharing code from that mod to other modules.

Advantages

The rules for namespace management are very simple. The source of each identifier is represented in an intuitive way. x.ObjIs

Obj Means that an object called is defined in a module called x.

Disadvantages

Module names can conflict. And the names of some modules can be inconveniently long.

recommend
  • import xShould be used to import packages and modules
  • from x import yIs xa package prefix, and ymeans that the module name, and yused to using a module without the prefix.
  • from x import y as zIs yused to import and use when there are multiple module names, or when the module name y is inconveniently long.
  • import y as zIs only zused when there is a lesser known convention. (numpy to np, or pandas to pd)

For example, it sound.effects.echoshould be imported as follows.

from sound.effects import echo

echo.EchoFilter(input, output, delay=0.7, atten=4)

When importing, the realtive name is not used. Even if modules are in the same package, they are imported using the full package name.

This avoids accidentally importing the package twice.

2.3 packages

Import each module by specifying the full path of the module location.

Advantages

You can avoid collisions caused by incorrect imports or names of modules that occur by navigating the module path differently from the developer’s expectations.

Disadvantages

As you develop, you make code distribution difficult by modifying the package hierarchy. However, this is not a problem for the modern deployment process.

recommend

Newly developed code must be imported by specifying the full package path.

YES:

## Reference absl.flags in code with the complete name (verbose).
import absl.flags
from doctor.who import jodie

FLAGS = absl.flags.FLAGS
## Reference flags in code with just the module name (common).
from absl import flags
from doctor.who import jodie

FLAGS = flags.FLAGS

NO:(This file is in the doctor/who directory, assuming the jodie.py file is also in this path)

## Unclear what module the author wanted and what will be imported.  The actual
## import behavior depends on external factors controlling sys.path.
## Which possible jodie module did the author intend to import?
import jodie

This sys.pathmay not be a problem because it will find the path and import the module, but it may not be possible depending on the environment. The Python package import process first looks for third-party or top-level packages, then local packages, so jodie.pymay not be imported correctly.

2.4 Exceptions

Exceptions are allowed in Python, but exception handling must be used with care.

Justice

Exceptions are created to handle errors or exception conditions that break the normal code flow or code control.

Advantages

Exception handling code has the advantage of not breaking the general code flow and process when an exception occurs.

Disadvantages

Exception handling code can confuse the general process and flow. It’s easy to miss errors when making library calls (It told me to use branch statements instead of exception handling code as much as possible,)

recommend

Exceptions must be used with certain conditions.

  • Use the built-in (built-in) exceptions only when it really makes sense. For example ValueError, raises for values ​​that do not pass the precondition (e.g., if only positive values ​​have to be entered, but -precondition- an ValueErrorexception occurs if the input is negative ).
  • assertDo not use the syntax to check arguments in public APIs. assertThe syntax is used for internal checks, not to confirm correct use or unexpected results.
Yes:
  def connect_to_next_port(self, minimum):
    """Connects to the next available port.

    Args:
      minimum: A port value greater or equal to 1024.

    Returns:
      The new minimum port.

    Raises:
      ConnectionError: If no available port is found.
    """
    if minimum < 1024:
      ## Note that this raising of ValueError is not mentioned in the doc
      ## string's "Raises:" section because it is not appropriate to
      ## guarantee this specific behavioral reaction to API misuse.
      raise ValueError(f'Min. port must be at least 1024, not {minimum}.')
    port = self._find_next_open_port(minimum)
    if not port:
      raise ConnectionError(
          f'Could not connect to service on port {minimum} or higher.')
    assert port >= minimum, (
        f'Unexpected port {port} when minimum was {minimum}.')
    return port
  def connect_to_next_port(self, minimum):
    """Connects to the next available port.

    Args:
      minimum: A port value greater or equal to 1024.

    Returns:
      The new minimum port.
    """
    assert minimum >= 1024, 'Minimum port must be at least 1024.'
    port = self._find_next_open_port(minimum)
    assert port is not None
    return port

Further explanation

  • The minimum received as an argument is treated as a conditional statement in YES, and if it is not correct, a rasie exception is issued. Do not use the assert statement.

  • Libraries and packages have their own exceptions. These exceptions are implemented by inheriting the existing exceptions.

  • The exception name must Errorend with.

  • Never except:use syntax to catch all exceptions . ( ExceptionOr StandardError)

  • If you use it as above, you will catch all exceptions such as typos, interrupts, shutdown calls, etc., making it difficult to find the desired error.

  • try/exceptBlocks in the syntax must be short. That way, you won’t catch other exceptions that the developer didn’t predict (write try, except short for each debugging point)

  • finallyIt is recommended to use sentences. You can use the syntax to handle when no exception occurs. This is useful in situations such as cleanup and closing files.

Global variables

Refrain from using

2.5.1 Definition

Variables defined as module level or class attribute

Advantages

Sometimes useful

Disadvantages

It has the potential to do something other than what you want while importing. This is because when a module is imported, it becomes a global variable assignment.

recommend

Avoid using global variables as much as possible.

However, module level constants are allowed and recommended. For example MAX_HOLY_HANDGRENADE_COUNT = 3, constants are all capitalized and used as underscores.

If used, it is assigned immediately when the module is imported, and is _used with prefixed to prevent malfunction .

Comprehension and Generator

Okay for simple cases

Justice

Lists, dictionaries, three Comfrey hensyeon the generator, generator expressions map()filter()lambdauseful because it’ll make the air conditioner not datatypes not use or iterator

Advantages

Simple comprehensions make the logic for creating lists, dictionaries, and sets simpler and cleaner. Generator expressions are also very useful (if you don’t have to make all the lists and you can break them in the middle).

Disadvantages

Complex comprehensions and generators are less readable

recommend

Use only for simple cases. Complex logic should use loops and loops

Yes:
  result = [mapping_expr for value in iterable if filter_expr]

  result = [{'key': value} for value in iterable
            if a_long_filter_expression(value)]

  result = [complicated_transform(x)
            for x in iterable if predicate(x)]

  descriptive_name = [
      transform({'key': key, 'value': value}, color='black')
      for key, value in generate_iterable(some_input)
      if complicated_condition_is_met(key, value)
  ]

  result = []
  for x in range(10):
      for y in range(5):
          if x * y > 10:
              result.append((x, y))

  return {x: complicated_transform(x)
          for x in long_generator_function(parameter)
          if x is not None}

  squares_generator = (x**2 for x in range(10))

  unique_names = {user.name for user in users if user is not None}

  eat(jelly_bean for jelly_bean in jelly_beans
      if jelly_bean.color == 'black')
No:
  result = [complicated_transform(
                x, some_argument=x+1)
            for x in iterable if predicate(x)]

  result = [(x, y) for x in range(10) for y in range(5) if x * y > 10]

  return ((x, y, z)
          for x in range(5)
          for y in range(5)
          if x != y
          for z in range(5)
          if y != z)

Basic iterators and operators

Using basic iterators and operations on lists, dictionaries, and files

Justice

Membership test operators (in, not in) and iterators defined on container data types (lists, dictionaries)

Advantages

Basic iterators and operations are very efficient and simple.

recommend
Yes:  for key in adict: ...
      if key not in adict: ...
      if obj in alist: ...
      for line in afile: ...
      for k, v in adict.items(): ...
      for k, v in six.iteritems(adict): ...
No:   for key in adict.keys(): ...
      if not adict.has_key(key): ...
      for line in afile.readlines(): ...
      for k, v in dict.iteritems(): ...

Download Details:

Author: kimsehwan96

Demo: http://sehwan96.com.s3-website.ap-northeast-2.amazonaws.com/

Source Code: https://github.com/kimsehwan96/car-iot-platform-from-kpu

#react #reactjs #javascript

What is GEEK

Buddha Community

Korea Polytechnic University Graduation Works Team Repository
Chet  Lubowitz

Chet Lubowitz

1595429220

How to Install Microsoft Teams on Ubuntu 20.04

Microsoft Teams is a communication platform used for Chat, Calling, Meetings, and Collaboration. Generally, it is used by companies and individuals working on projects. However, Microsoft Teams is available for macOS, Windows, and Linux operating systems available now.

In this tutorial, we will show you how to install Microsoft Teams on Ubuntu 20.04 machine. By default, Microsoft Teams package is not available in the Ubuntu default repository. However we will show you 2 methods to install Teams by downloading the Debian package from their official website, or by adding the Microsoft repository.

Install Microsoft Teams on Ubuntu 20.04

1./ Install Microsoft Teams using Debian installer file

01- First, navigate to teams app downloads page and grab the Debian binary installer. You can simply obtain the URL and pull the binary using wget;

$ VERSION=1.3.00.5153
$ wget https://packages.microsoft.com/repos/ms-teams/pool/main/t/teams/teams_${VERSION}_amd64.deb

#linux #ubuntu #install microsoft teams on ubuntu #install teams ubuntu #microsoft teams #teams #teams download ubuntu #teams install ubuntu #ubuntu install microsoft teams #uninstall teams ubuntu

Aditya Goswami

Aditya Goswami

1613637410

How To Hire Dedicated Software Development Team

We all have been agreeing that we need to take the help of top talent to fulfill the requirements of our complex tasks at some business point. Sometimes, your in-housing team fails to match client’s requirements, or we can say market needs. At that moment, you need to take one step forward and hire dedicated software development team to match the client’s requirements and market trends. Before going ahead, take a look at the dedicated development team model.

When you are going to do a partnership with a software development company, a dedicated software development team is one method. On the other hand, fixed price and time are other models. Every model has its uniqueness, benefits, and drawbacks. Let’s talk about a dedicated development team.

When clients look for a dedicated team for software development, they want to hire a team of developers to fulfill the tasks of the complex project. That team of developers collaborates with the in-housing squad, although they work remotely. They take responsibility for the project and try to make the project successful. They dedicate themselves to match all requirements of the project in the market or the latest trends.

How To Hire Dedicated Software Development Team

Dedicated software development team - Talents

  • Backend and frontend developers
  • Project manager
  • Business analysts
  • DevOps
  • UX/UI designers
  • Quality assurance engineers

When hiring a development team is a Good Choice?

  • When you have some complex project, and the in-housing team is inexperienced.

  • When you don’t have a resource of the dedicated web development team to match the complexity of your projects.

  • When you want to take your business to the next level in terms of client satisfaction and expertise.

  • When you have multiple projects aligned with the same deadlines, a software development dedicated team is an excellent choice to go with.

  • When you don’t have enough time to hire a team of developers for your in-house.

  • When you expand your business with a dedicated software development team, they take care of your specific needs and reach out to all the possible and desired objectives.

Benefits of outsourcing a dedicated team

Because of the following reasons, you need to hire development teams for your business.

Cost-effectiveness
When looking for a dedicated development team for hire, you do not require to spend your valuable time hiring IT specialists individually and forming a team. You also not needed to build an infrastructure for them. They will work remotely with their resources, so there is no additional cost. They can start working on your project by the time you hire dedicated team, and there is no delay or settlement needed.

Focus on the projec

The software dedicated development team you hire does the work for only your project during the set time period. So, their full focus is solely on your project.
You can also check the work process and get updates regarding your project regularly. This collaboration takes your project to the next level and provides the best satisfaction to the clients.

Flexible approach

A dedicated development team is the best choice for large-scale projects. It gives you one benefit: if you require more developers between the projects or want to cut down your team size, you can do it. Dedicated developers are very flexible; they take any issues and react to get the best output accordingly.

Maximum effect and speed

They understand your business goals and understand the importance of matching deadlines. They keep track of work progress, so they can give you the reports of completed tasks and future outlines if you ask. You will get maximum efficiency and high speed with a dedicated team for software development.

After knowing the advantages of developers outsourcing dedicated teams, we are now going to look at how to hire dedicated software development team.

How to hire dedicated software development team?

Hire a development team for your organization is a stressful task for organizations as you need to focus on several factors. I know it is a crucial task for your organization, but stress, you do not need to think about. A few ways are available to hire a dedicated software development team for your organization, like finding them from Google organic search or B2B portals.

Narrowing down your search, and select partner through:

  • Google top 10 result
  • B2B portal (Clutch)
  • Freelance workplaces (Upwork)
  • StackOverflow
  • GitHub

How to Set-up, a dedicated software development team?

After choosing your offshore partner, now it’s time to follow the process for setting up your dedicated development team.

Well-defined business objectives are needed.

You need to explain all your business requirements, including the deadline and desired workflow you wanted, development team size, and type of expertise you require.

**Assembling the team **

Individual hiring can take one or more months, but with a dedicated team model, you bring your team to your work within one week.

Talent selection

After finding a dedicated team, selected the best-qualified team for your project with factors like expertise, efficiency, tech skill, English fluency, and other aspects of your project.

Integrating the team

After selecting the team based on your skills requirements, the group joins the project in progress quickly. Now, we can say business owners take the best step to get a business boost soon in the market.

Criteria that you need to look at while hiring a dedicated team.

With this model, you hire a development team and start working on your project like your in-housing team. For making any product successful, you must have to look for the right developers and team members. Here we will look at a few criteria you need to keep in mind while hiring a dedicated development team.

Portfolio: Take note that whether the team you are hiring is proved the portfolio or not

Reviews: Take a look at the reviews of that dedicated team.

Skillset: Make sure the dedicated team matches all the skills you require.

Language: Take note that the dedicated team has a good command of language.

Cost: Make sure the decided price is not beyond your budget.

The number of members: Based on your project deadline, decide the number of developers you require.

Wrapping Up

Being a business person, everyone wants the best for their business. No one wants their business to perform poorly and not be able to fulfill the market requirements. If your business is going in the wrong direction, it is time for you to call a dedicated team to lift your business up.

#dedicated software development team #hire dedicated software development team #software development dedicated team #dedicated team for software development #hire dedicated development team #hire development team

Korea Polytechnic University Graduation Works Team Repository

Sanki University graduation work team repository

url : http://sehwan96.com.s3-website.ap-northeast-2.amazonaws.com/

  • Directory organization
/
front_codes
    - react-app
    README.md
backend_codes
    - platfrom code
    REAMDE.md
test_codes
    - 테스트 디렉터리들
  • In the master branch, each branch works.
  • Branch convention: {contents}/{parts}/{details}
  • There are a total of 4 contents. feature, bugfix, hotfix, enhancement
  • 예제 : feature/front/add-react-app
  • 예제 : feature/back/fix-aws-resources
  • When your work is done, push to your branch and write a PR.
git branch feature/back/fix-aws-resources
git checkout feature/back/fix-aws-resources
git pull origin master --rebase
- 본인의 작업 실시 -
- 완료 되었을 경우-
git add *
git commit -m "add some validation logic"
git push origin feature/back/fix-aws-resources
- 이후 깃헙에 들어가서 PR 작성 및 리뷰 리퀘스트 -
  • Receive a review from the team leader (Kim Se-hwan) and merge the PR.

distribute

  • The front code is automatically deployed and deployed using the github action. (Whenever a push event occurs on the master branch, it is uploaded to the S3 bucket)
name : React build 
on : 
   push :                                ## Run only when a push event occurs in the master branch 
    branches :
      - master

jobs:
  build:
    runs-on: ubuntu-18.04
    steps:
      - name The : Checkout, the Source code.   ## Check out repository 
        uses : actions/checkout@master

      - name: Cache node modules      ## node modules 캐싱
        uses: actions/cache@v1
        with:
          path: front_codes/my-app/node_modules
          key: ${{ runner.OS }}-build-${{ hashFiles('**/package-lock.json') }}
          restore-keys: |
            ${{ runner.OS }}-build-
            ${{ runner.OS }}-

      - name: Display the path
        run: pwd && ls

      - name The : the Change Directory ## directory, moving 
        the Run : the CD front_codes / My-the App

      - name The : the Install the Dependencies     ## dependent files installed 
        the Run : the CD front_codes / My-npm the install the App &&

      - name: Build                   ## React Build
        run: cd front_codes/my-app && npm run build

      - name: Deploy                  ## S3에 배포하기
        env:
          AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
          AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
        run: |
          aws s3 cp \
            --recursive \
            --region ap-northeast-2 \
            front_codes/my-app/build s3://sehwan96.com ## 

Skill stack used

  1. AWS
  • DynamoDB
  • RDS(Postgresql)
  • Lambda
  • GreenGrass
  • Appsync
  • GraphQL
  • Amplify
  • S3
  • CloudWatch
  1. Front
  • React.js
  • Material UI
  • D3.js
  • webpack
  • yarn
  • above sea level
  1. DevOps
  • Jenkins
  • Serverless(with AWS)
  • Docker(Greengrass Deploy)

Google Python Coding-Style Translation (Translator Se-Hwan Kim)

Original: https://google.github.io/styleguide/pyguide.html

1 Background

Python is a very active main language language at Google. This style guide has listed do’s and don’ts for coding Python.

To make coding auto-formatting accurate, I created a setting file for Vim (for Vim users).

" Copyright 2019 Google LLC
"
" Licensed under the Apache License, Version 2.0 (the "License");
" you may not use this file except in compliance with the License.
" You may obtain a copy of the License at
"
"    https://www.apache.org/licenses/LICENSE-2.0
"
" Unless required by applicable law or agreed to in writing, software
" distributed under the License is distributed on an "AS IS" BASIS,
" WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
" See the License for the specific language governing permissions and
" limitations under the License.

" Indent Python in the Google way.

setlocal indentexpr=GetGooglePythonIndent(v:lnum)

let s:maxoff = 50 " maximum number of lines to look backwards.

function GetGooglePythonIndent(lnum)

  " Indent inside parens.
  " Align with the open paren unless it is at the end of the line.
  " E.g.
  "   open_paren_not_at_EOL(100,
  "                         (200,
  "                          300),
  "                         400)
  "   open_paren_at_EOL(
  "       100, 200, 300, 400)
  call cursor(a:lnum, 1)
  let [par_line, par_col] = searchpairpos('(\|{\|\[', '', ')\|}\|\]', 'bW',
        \ "line('.') < " . (a:lnum - s:maxoff) . " ? dummy :"
        \ . " synIDattr(synID(line('.'), col('.'), 1), 'name')"
        \ . " =~ '\\(Comment\\|String\\)$'")
  if par_line > 0
    call cursor(par_line, 1)
    ifpar_col ! =  col ( " $ " ) -  1 
      return par_col
     endif 
  endif

  " Delegate the rest to the original function.
  return GetPythonIndent(a:lnum)

endfunction

let pyindent_nested_paren="&sw*2"
let pyindent_open_paren="&sw*2"

(We won’t write)

2 Python rules

2.2 Imports

import The syntax is not used to import each class or function,

Justice

It is a reusable mechanism for sharing code from that mod to other modules.

Advantages

The rules for namespace management are very simple. The source of each identifier is represented in an intuitive way. x.ObjIs

Obj Means that an object called is defined in a module called x.

Disadvantages

Module names can conflict. And the names of some modules can be inconveniently long.

recommend
  • import xShould be used to import packages and modules
  • from x import yIs xa package prefix, and ymeans that the module name, and yused to using a module without the prefix.
  • from x import y as zIs yused to import and use when there are multiple module names, or when the module name y is inconveniently long.
  • import y as zIs only zused when there is a lesser known convention. (numpy to np, or pandas to pd)

For example, it sound.effects.echoshould be imported as follows.

from sound.effects import echo

echo.EchoFilter(input, output, delay=0.7, atten=4)

When importing, the realtive name is not used. Even if modules are in the same package, they are imported using the full package name.

This avoids accidentally importing the package twice.

2.3 packages

Import each module by specifying the full path of the module location.

Advantages

You can avoid collisions caused by incorrect imports or names of modules that occur by navigating the module path differently from the developer’s expectations.

Disadvantages

As you develop, you make code distribution difficult by modifying the package hierarchy. However, this is not a problem for the modern deployment process.

recommend

Newly developed code must be imported by specifying the full package path.

YES:

## Reference absl.flags in code with the complete name (verbose).
import absl.flags
from doctor.who import jodie

FLAGS = absl.flags.FLAGS
## Reference flags in code with just the module name (common).
from absl import flags
from doctor.who import jodie

FLAGS = flags.FLAGS

NO:(This file is in the doctor/who directory, assuming the jodie.py file is also in this path)

## Unclear what module the author wanted and what will be imported.  The actual
## import behavior depends on external factors controlling sys.path.
## Which possible jodie module did the author intend to import?
import jodie

This sys.pathmay not be a problem because it will find the path and import the module, but it may not be possible depending on the environment. The Python package import process first looks for third-party or top-level packages, then local packages, so jodie.pymay not be imported correctly.

2.4 Exceptions

Exceptions are allowed in Python, but exception handling must be used with care.

Justice

Exceptions are created to handle errors or exception conditions that break the normal code flow or code control.

Advantages

Exception handling code has the advantage of not breaking the general code flow and process when an exception occurs.

Disadvantages

Exception handling code can confuse the general process and flow. It’s easy to miss errors when making library calls (It told me to use branch statements instead of exception handling code as much as possible,)

recommend

Exceptions must be used with certain conditions.

  • Use the built-in (built-in) exceptions only when it really makes sense. For example ValueError, raises for values ​​that do not pass the precondition (e.g., if only positive values ​​have to be entered, but -precondition- an ValueErrorexception occurs if the input is negative ).
  • assertDo not use the syntax to check arguments in public APIs. assertThe syntax is used for internal checks, not to confirm correct use or unexpected results.
Yes:
  def connect_to_next_port(self, minimum):
    """Connects to the next available port.

    Args:
      minimum: A port value greater or equal to 1024.

    Returns:
      The new minimum port.

    Raises:
      ConnectionError: If no available port is found.
    """
    if minimum < 1024:
      ## Note that this raising of ValueError is not mentioned in the doc
      ## string's "Raises:" section because it is not appropriate to
      ## guarantee this specific behavioral reaction to API misuse.
      raise ValueError(f'Min. port must be at least 1024, not {minimum}.')
    port = self._find_next_open_port(minimum)
    if not port:
      raise ConnectionError(
          f'Could not connect to service on port {minimum} or higher.')
    assert port >= minimum, (
        f'Unexpected port {port} when minimum was {minimum}.')
    return port
  def connect_to_next_port(self, minimum):
    """Connects to the next available port.

    Args:
      minimum: A port value greater or equal to 1024.

    Returns:
      The new minimum port.
    """
    assert minimum >= 1024, 'Minimum port must be at least 1024.'
    port = self._find_next_open_port(minimum)
    assert port is not None
    return port

Further explanation

  • The minimum received as an argument is treated as a conditional statement in YES, and if it is not correct, a rasie exception is issued. Do not use the assert statement.

  • Libraries and packages have their own exceptions. These exceptions are implemented by inheriting the existing exceptions.

  • The exception name must Errorend with.

  • Never except:use syntax to catch all exceptions . ( ExceptionOr StandardError)

  • If you use it as above, you will catch all exceptions such as typos, interrupts, shutdown calls, etc., making it difficult to find the desired error.

  • try/exceptBlocks in the syntax must be short. That way, you won’t catch other exceptions that the developer didn’t predict (write try, except short for each debugging point)

  • finallyIt is recommended to use sentences. You can use the syntax to handle when no exception occurs. This is useful in situations such as cleanup and closing files.

Global variables

Refrain from using

2.5.1 Definition

Variables defined as module level or class attribute

Advantages

Sometimes useful

Disadvantages

It has the potential to do something other than what you want while importing. This is because when a module is imported, it becomes a global variable assignment.

recommend

Avoid using global variables as much as possible.

However, module level constants are allowed and recommended. For example MAX_HOLY_HANDGRENADE_COUNT = 3, constants are all capitalized and used as underscores.

If used, it is assigned immediately when the module is imported, and is _used with prefixed to prevent malfunction .

Comprehension and Generator

Okay for simple cases

Justice

Lists, dictionaries, three Comfrey hensyeon the generator, generator expressions map()filter()lambdauseful because it’ll make the air conditioner not datatypes not use or iterator

Advantages

Simple comprehensions make the logic for creating lists, dictionaries, and sets simpler and cleaner. Generator expressions are also very useful (if you don’t have to make all the lists and you can break them in the middle).

Disadvantages

Complex comprehensions and generators are less readable

recommend

Use only for simple cases. Complex logic should use loops and loops

Yes:
  result = [mapping_expr for value in iterable if filter_expr]

  result = [{'key': value} for value in iterable
            if a_long_filter_expression(value)]

  result = [complicated_transform(x)
            for x in iterable if predicate(x)]

  descriptive_name = [
      transform({'key': key, 'value': value}, color='black')
      for key, value in generate_iterable(some_input)
      if complicated_condition_is_met(key, value)
  ]

  result = []
  for x in range(10):
      for y in range(5):
          if x * y > 10:
              result.append((x, y))

  return {x: complicated_transform(x)
          for x in long_generator_function(parameter)
          if x is not None}

  squares_generator = (x**2 for x in range(10))

  unique_names = {user.name for user in users if user is not None}

  eat(jelly_bean for jelly_bean in jelly_beans
      if jelly_bean.color == 'black')
No:
  result = [complicated_transform(
                x, some_argument=x+1)
            for x in iterable if predicate(x)]

  result = [(x, y) for x in range(10) for y in range(5) if x * y > 10]

  return ((x, y, z)
          for x in range(5)
          for y in range(5)
          if x != y
          for z in range(5)
          if y != z)

Basic iterators and operators

Using basic iterators and operations on lists, dictionaries, and files

Justice

Membership test operators (in, not in) and iterators defined on container data types (lists, dictionaries)

Advantages

Basic iterators and operations are very efficient and simple.

recommend
Yes:  for key in adict: ...
      if key not in adict: ...
      if obj in alist: ...
      for line in afile: ...
      for k, v in adict.items(): ...
      for k, v in six.iteritems(adict): ...
No:   for key in adict.keys(): ...
      if not adict.has_key(key): ...
      for line in afile.readlines(): ...
      for k, v in dict.iteritems(): ...

Download Details:

Author: kimsehwan96

Demo: http://sehwan96.com.s3-website.ap-northeast-2.amazonaws.com/

Source Code: https://github.com/kimsehwan96/car-iot-platform-from-kpu

#react #reactjs #javascript

Alice Cook

Alice Cook

1614329473

Fix: G Suite not Working | G Suite Email not Working | Google Business

G Suite is one of the Google products, developed form of Google Apps. It is a single platform to hold cloud computing, collaboration tools, productivity, software, and products. While using it, many a time, it’s not working, and users have a question– How to fix G Suite not working on iPhone? It can be resolved easily by restarting the device, and if unable to do so, you can reach our specialists whenever you want.
For more details: https://contactforhelp.com/blog/how-to-fix-the-g-suite-email-not-working-issue/

#g suite email not working #g suite email not working on iphone #g suite email not working on android #suite email not working on windows 10 #g suite email not working on mac #g suite email not syncing

Xfinity Stream Not Working?

Xfinity, the tradename of Comcast Cable Communications, LLC, is the first rate supplier of Internet, satellite TV, phone, and remote administrations in the United States. Presented in 2010, previously these administrations were given under the Comcast brand umbrella. Xfinity makes a universe of mind boggling amusement and innovation benefits that joins a great many individuals to the encounters and minutes that issue them the most. Since Xfinity is the greatest supplier of link administrations and home Internet in the United States, it isn’t amazing that the organization gets a ton of investigating and inquiry goal demands on its telephone based Xfinity Customer Service.

#my internet is not working comcast #comcast tv remote not working #my xfinity internet is not working #xfinity stream not working #xfinity wifi hotspot not working