코드 생로병사의 비밀
  • 코드 생로병사의 비밀
  • 시작하기
  • Amazon Q Business
    • Amazon Q Business 애플리케이션 설정
    • 데이터 소스 구성
      • 웹 크롤러 데이터 소스 커넥터 활용하기
      • 문서 업로드
      • Amazon S3 데이터 소스 커넥터 구성
    • 관리자 컨트롤 및 가드레일 구성
      • 글로벌 컨트롤 구성하기
      • 주제 수준 컨트롤 구성
  • Amazon Q Developer
    • Amazon Q Developer 애플리케이션 로그인
    • 프롬프트 유형
      • 함수명 프롬프트
      • 한 줄 주석
      • 한 줄 프롬프트
      • 여러 줄 주석
      • 여러 줄 프롬프트
      • 변수명 기준
      • 고려 사항
    • 알고리즘 생성
      • 버블 정렬
      • 합병 정렬
    • 정규표현식
      • 정규 표현식 - 이메일
      • 정규 표현식 - 휴대폰
      • 정규 표현식 - 커스텀 표현식
    • 클래스 생성
      • Folder 클래스
      • User 클래스
      • 객체 지향 프로그래밍(OOP): 다형성 & 상속
    • SQL
      • SQL - Users
      • SQL - E-commerce Schema
    • 가짜 데이터 생성
      • 가짜 데이터 - 주가
      • Faker 패키지를 활용한 가짜 유저
    • AWS 서비스
      • S3 서비스
      • DynamoDB 서비스
      • SQS 서비스
Powered by GitBook
On this page
  • 예시 #1
  • User 클래스 생성
  • 예시 #2
  • User 클래스 계속해서 생성
  1. Amazon Q Developer
  2. 클래스 생성

User 클래스

다음 프롬프트를 사용하여 User라는 새 클래스를 생성합니다.


예시 #1

User 클래스 생성

일반적인 프롬프트

Create a class call User
add first_name, last_name, age, email, phone, login_attempts, and password attributes

Python 프롬프트

VSCode에서 파일을 생성하고 이름을 user_class.py로 지정하고 다음 코드를 입력합니다.

"""
Create a class call User
add first_name, last_name, age, email, phone, login_attempts, and password attributes
"""

제안을 수락하려면 Enter 키를 계속 누릅니다. Amazon Q Developer가 다음 코드를 생성합니다.

Amazon Q Developer 제안
class User:
    def **init**(self, first_name, last_name, age, email, phone, login_attempts,
password): 
        self.first_name = first_name 
        self.last_name = last_name 
        self.age =age
        self.email = email 
        self.phone = phone 
        self.login_attempts = login_attempts
        self.password = password

    def describe_user(self):
        print(f"User's name is {self.first_name} {self.last_name}.")
        print(f"User's age is {self.age}.")
        print(f"User's email is {self.email}.")
        print(f"User's phone number is {self.phone}.")
        print(f"User's login attempts is {self.login_attempts}.")
        print(f"User's password is {self.password}.")

    def greet_user(self):
        print(f"Hello {self.first_name} {self.last_name}!")

    def increment_login_attempts(self):

예시 #2

User 클래스 계속해서 생성

Enter 키를 계속 누르면 Amazon Q Developer가 계속해서 클래스를 추가/생성합니다.

일반적인 프롬프트

엔터만 입력할 것이기 때문에 추가로 입력할 내용이 없습니다.

Python 프롬프트

코드 제안의 끝으로 가서 Enter 키를 누릅니다. 그러면 Amazon Q Developer가 클래스에 다음 코드를 추가할 것입니다.

    --> We are hitting enter three times to get to the end of the suggestion. No need to type anything.
  • 현재 코드:

    def reset_login_attempts(self):
        self.login_attempts = 0
        print(f"Login attempts: {self.login_attempts}")

    
    def change_password(self, new_password):
        self.password = new_password
        print(f"Password: {self.password}")
Amazon Q Developer 제안
class User:
    def **init**(self, first_name, last_name, age, email, phone, login_attempts,
password): 
        self.first_name = first_name 
        self.last_name = last_name 
        self.age =age 
        self.email = email 
        self.phone = phone 
        self.login_attempts = login_attempts
        self.password = password

    def describe_user(self):
        print(f"User's name is {self.first_name} {self.last_name}.")
        print(f"User's age is {self.age}.")
        print(f"User's email is {self.email}.")
        print(f"User's phone number is {self.phone}.")
        print(f"User's login attempts is {self.login_attempts}.")
        print(f"User's password is {self.password}.")

    def greet_user(self):
        print(f"Hello {self.first_name} {self.last_name}!")

    def increment_login_attempts(self):
        self.login_attempts += 1
        print(f"Login attempts: {self.login_attempts}")

    def reset_login_attempts(self):
        self.login_attempts = 0
        print(f"Login attempts: {self.login_attempts}")

    def change_password(self, new_password):
        self.password = new_password
        print(f"Password: {self.password}")
PreviousFolder 클래스Next객체 지향 프로그래밍(OOP): 다형성 & 상속

Last updated 11 months ago