Code Monkey home page Code Monkey logo

python-utils's Introduction

Random python utils I'm making for my own use. Also using this to apply some basic OOP

pip install wise-py-utils
>>> from wise.<util_file> import <UtilClass>

# Example:
>>> from wise.datetimeutils import GetDay

Enter the specific directory to get more about each utility.

๐Ÿ—“๏ธ datetime-utils

Returns a string containing the weekday of the current or specified date.

๐Ÿ’ป cpu-utils

๐Ÿ“ typo-remover

In depth info

Datetime utils

The python datetime module is very versatile however as shown in this stackoverflow answer. Getting a date's weekday as a string is not so simple. Python's datetime. datetime.weekday() returns an integer, 0 for Monday ... ... and 6 for Sunday.

This module allows me to get a string containing the date (current or otherwise specified) with a single method.

Examples

Simply get the current day of the week

today = GetDay()
print(today.get_weekday())

Output:
'Saturday'

Get the day of a specified date

from datetime import datetime
today = GetDay(datetime(2017, 2, 2))
print(today.get_weekday())

Output:
'Thursday'

Get the day based on the weekday number using the `get_weekday_from_number() classmethod

>>> import datetime
>>> number = datetime.datetime.today().weekday()
>>> print(number)
1
>>> print(GetDay.get_weekday_from_number(number))
'Tuesday'

Enter typos

Often when hitting enter, I accidentally hit a key next to it. Often the resulting input can end up looking like this.

characters = ["/", "'" "\" "]"]
input = "<regular input> <random-character><enter>"

This library is designed to remove trailing special characters from strings and integers and return what the user actually mean to enter.

Scan files

Scans a specified file for a regex or string pattern and returns a list of all the results`

python-utils's People

Contributors

techwiz-3 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.