A question from my childhood answered

A question from my childhood answered

https://ift.tt/3nPQIGt

I saw this posted at Wirecutter’s.

I grew up with the audiobooks of James Herriot’s All Creatures Great and Small series, narrated by Christopher Timothy, who played James Herriot MRCVS in the BBC series (which I also love).

A few times n the book series, James mentions having to put down an animal with a humane killer.  I never knew that was a specific device until I saw this video.

I found this extremely interesting because it answered a question from my childhood that I never knew I had.

guns

via https://gunfreezone.net

December 26, 2020 at 06:25AM

How Gift Wrapping Paper is Made: Rotary Screen Printing

How Gift Wrapping Paper is Made: Rotary Screen Printing

https://ift.tt/2KvoT85

If you thought gift wrapping paper was wasteful as an end product, wait ’til you see the production method. In rotary screen printing, each color requires its own copper cylinder:

Source

Here’s a more in-depth look at how the process works:

I’ll stick with newspaper.

fun

via Core77 https://ift.tt/1KCdCI5

December 23, 2020 at 12:49PM

CMMG Releases Shortest and Most Compact BANSHEE .22LR AR-15

CMMG Releases Shortest and Most Compact BANSHEE .22LR AR-15

https://ift.tt/34CMB96

CMMG Releases Shortest and Most Compact BANSHEE .22LR AR-15
CMMG Releases Shortest and Most Compact BANSHEE .22LR AR-15

U.S.A.-(AmmoLand.com)- CMMG is proud to introduce the shortest and most compact BANSHEE to date. This new line-up is chambered in .22LR and features a capped lower receiver with no buffer tube (receiver extension).

This ultra-compact BANSHEE is made possible by CMMG’s new .22LR End Cap – which is a new way to transform your .22LR AR15 build.

The .22LR End Cap is the perfect accessory that shortens your .22LR AR15 by replacing the need for a receiver extension and buffer assembly. The .22LR End Cap is compatible with all CMMG .22LR AR Conversion Kits, as well as any AR15 that uses a dedicated CMMG .22LR bolt carrier group and barrel.

The .22LR End Cap is available in two variations: standard, with a smooth exterior and CMMG logo (.22LR End Cap LOGO), and QD (quick-detach), which has an attachment point machined into the exterior for attaching a QD sling. Installing the .22LR End Cap is made easy by securing the .22LR End Cap on the back of the lower receiver with a 3/8” hex wrench, in lieu of the buffer tube.

The .22LR End Cap with CMMG logo can be purchased separately for $24.95 and the QD End Cap for $29.95.

.22LR End Cap with CMMG logo (left) QD End Cap (Right)
.22LR End Cap with CMMG logo (left) QD End Cap (Right)

BANSHEE lower groups and complete BANSHEE .22LR pistols are offered with the .22 LR End Cap preinstalled: the BANSHEE 100 Series comes with the .22 LR End Cap LOGO and the BANSHEE 200 and 300 Series come with the QD End Cap. MSRP on the complete BANSHEE pistols range from $799.95 to $1,024.95.

For more information on the .22LR End Cap and all BANSHEE models, please visit www.CMMGinc.com.

CMMG Guarantee:

All CMMG products are covered under the CMMG Lifetime Quality Guarantee. Conditioned on being a Limited Warranty of use, maintenance, and cleaning of the product in accordance with CMMG, Inc.’s instructions to be free of defects in material and workmanship. CMMG will repair, replace or substitute part(s) as determined in the sole and absolute discretion of CMMG Inc at no charge to the purchaser or provider. Complete limited warranty information can be found at CMMGinc.com/tech-support


About CMMG:

CMMG began in central Missouri in 2002 and quickly developed into a full-time business because of its group of knowledgeable and passionate firearms enthusiasts committed to quality and service. Its reputation was built on attention to detail, cutting edge innovation and the superior craftsmanship that comes from sourcing all their own parts. By offering high quality AR rifles, parts and accessories, CMMG’s commitment to top-quality products and professional service is as deep today as it was when it began.

For more information, visit CMMGinc.comCMMG logo

The post CMMG Releases Shortest and Most Compact BANSHEE .22LR AR-15 appeared first on AmmoLand.com.

guns

via AmmoLand.com https://ift.tt/2okaFKE

December 23, 2020 at 01:07PM

Laravel Python Package

Laravel Python Package

https://ift.tt/3nHOtoy


LaravelPython

Execute Python scripts inside your Laravel Application.

Installation

composer require robertogallea/laravel-python

Configuration

To edit the default package configuration, publish the config resource with the command

php artisan vendor:publish --provider="robertogallea\LaravelPython\ServiceProvider" --tag=config

then edit config/laravel-python.php

Usage

You can run commands in several ways:

  1. Instantiating LaravelPython service:
use robertogallea\LaravelPython\Services\LaravelPython;
...

$service = new LaravelPython();
$result = $service->run('/path/to/script.py'):
$parameters = array('par1', 'par2'):
$result = $service->run('/path/to/script.py', $parameters):
  1. Injecting from the ServiceContainer
use robertogallea\LaravelPython\Services\LaravelPython;
...
public function __construct(LaravelPython $service)
{
  $result = $service->run('/path/to/script.py')
  $parameters = array('par1', 'par2'):
  $result = $service->run('/path/to/script.py', $parameters):
}
  1. Using the Python facade
$result = \Python::run('/path/to/script.py')
$parameters = array('par1', 'par2'):
$result = \Python::run'/path/to/script.py', $parameters):
  1. Via command line with an artisan command
php artisan python:run /path/to/script.py "Some parameter"

Note that you can use an arbitrary number of parameters

Issues, Questions and Pull Requests

You can report issues and ask questions in the issues section. Please start your issue with ISSUE: and your question with QUESTION:

If you have a question, check the closed issues first. Over time, I’ve been able to answer quite a few.

To submit a Pull Request, please fork this repository, create a new branch and commit your new/updated code in there. Then open a Pull Request from your new branch. Refer to this guide for more info.

programming

via Laravel News Links https://ift.tt/2dvygAJ

December 21, 2020 at 08:42PM

Carol of the Mandalorian

Carol of the Mandalorian

https://ift.tt/3h5pvgA

Carol of the Mandalorian

Link

We might not be getting a Mandalorian holiday special any time soon, but if we ever do, we already have the theme song. AtinPiano’s mashup of Ludwig Göransson’s epic Mando score with the Christmas classic Carol of the Bells would fill the bill perfectly. They previously gave The Imperial March the holiday treatment.

fun

via The Awesomer https://theawesomer.com

December 21, 2020 at 05:45PM

untitled

untitled

https://ift.tt/3h3Hbt0

The season of gift-giving can cause a lot of stress as you worry about what to get, and how much it’s going to cost. Use these free sites to discover the best gifts to give while staying within your budget.

With the help of technology, there are some ingenious ways to find the best gift to give someone. Smart algorithms can analyze people’s Instagram profiles to uncover what they’ll like. You can create wishlists to share with friends or look through catalogs based on who you’re shopping for and their interests. And all while using tactics to save money.

1. Matchbox (Web): Match Person and Interests to Find Amazon Recommendations


Matchbox is a simple, easy-to-browse gift recommendation engine. In a three-step process, it shows curated gift ideas based on who you’re shopping for.

In the first step, select the person, such as a friend, sister, grandfather, mother, etc. Then add their age. In the second step, select that person’s primary interest from categories like organization, creativity, sports, etc.

Matchbox will then display a list of gift ideas, all of which are available on Amazon. You can filter this list further by price range or categories (i.e. Amazon store categories). Click the Heart to add anything that looks interesting to your wishlist for later. And you can quickly restart the search too, while your wishlist is stored.

2. Wishy.gift (Web): Create a Wishlist to Share With Close Friends

Image Gallery (2 Images)

Wishy.gift lets you create a wishlist of things you want, with links, and share them with friends
Expand
Participants in a Wishy.gift list can claim items they're buying as gifts
Expand

If you’re exchanging gifts with your family or a small group of friends, Wishy.gift’s shared wishlists will make shopping easier. It’s a simple free web app to add and claim items.

Once you register for an account, you can create a wishlist and share it with friends. Each item in the wishlist has space for a name or description and a link, which will make it easier for friends to buy the right item. You can also add multiple numbers of an item (like five pairs of socks) so that different people can claim one each.

As a recipient of a list, you can claim a gift idea so that there aren’t repeats. You can also see which items have already been claimed by others. It’s a remarkably easy mechanism to understand.

Wishy.gift is great for small groups where everyone is gifting everyone else. You can also use it for charities or donation drives, to lend a helpful hand during the holidays.

3. Random Gift Idea (Web): Tinder for Gifts


Can’t think of what gift to get for someone? Random Gift Idea has plenty of suggestions in a mobile-friendly website, using a Tinder-like interface where you swipe to discover more.

Swipe left to discard the current item for a new one. Swipe right to add an item to your wishlist. And find out more about any item by clicking the button to go to the product page.

Random Gift Idea has a few filters to narrow down the selection. You can set a price range from zero to 1000 dollars. And you can choose recipients like men, women, teen, baby, kids 4-7, and kids 8-12. It’s a fun way to window shop for the coolest things online.

4. Gifthub (Web): Gift Ideas Based on Instagram Profiles


People let out more about themselves on their social media profiles than they think. Gifthub analyzes a person’s Instagram profile to recommend gifts that they are bound to like. Just enter the username and let Gifthub work its magic. The products link to Amazon USA, and generally include an affiliate link.

You should get the username right otherwise Gifthub won’t work. The company also doesn’t explain how it arrives at the list of recommended products. When we tested it with our MakeUseOf Instagram account, it needed additional input on gender and age. That input wasn’t needed with personal accounts.

Gifthub also has a Telegram bot to help you pick gifts for friends. It’s a step-by-step chat based on multiple-choice answers, which will help Gifthub arrive at a suitable recommendation.

5. Wanderkind (Web): Creative Gifts to Educate and Entertain, for Kids and Adults


You can’t predict the impact that your gift will have. Gift a child their first set of watercolors and a paintbrush, and you might just inspire the next Picasso. Your aunt always loved music, and a harmonica might be the gift that unlocks unbridled joy in her. These are the types of gifts that entertain, educate, and delight. That’s what Wanderkind is all about.

Wanderkind collects gift ideas that focus on discovery, movement, learning, and creativity. It’s a carefully selected list of items that are built to last ("no cheap plastic" is a rule they adhere to), are a lot of fun for all ages, and spark an innate joy.

That said, Wanderkind is careful to pick items that look good as gifts, and aren’t simply utility pieces. For example, for a fantasy book lover, they recommend a well-crafted box set of The Lord of the Rings books. The gifts have a wide price range and come in a variety of categories.

6. How to Set Up a Christmas Budget (Web): Dave Ramsey’s Money Saving Advice


If you aren’t mindful of how much you are spending on each gift, you can quickly run over budget. In fact, credit card company reports show people taking on big debts during this time. If you want to save money over the holiday season, take personal finance guru Dave Ramsey’s advice on how to set up a Christmas budget.

In his blog post, Ramsey recommends making a zero-based budget. This means you won’t take on any debt, and includes tips like setting up a Christmas fund, tweaking budget lines, and being meticulous.

As usual, Ramsey recommends his app EveryDollar to put this into practice, but you can use any expense tracker or budgeting app. It’s universal advice that you could even put into use with a pen and paper.

A Digital, Distanced Christmas?

The COVID-19 pandemic forced the world indoors in 2020. With lockdowns, quarantines, and self-isolation, we have had to rethink how we celebrate holidays and go about our daily lives. Will this be a digital, socially distanced Christmas too?

However you choose to celebrate it, there are enough ways to make it enjoyable. More and more, people are finding solace through our digital world, whether it’s video chat parties or sharing your recipes online. And you can always exchange gifts digitally on Christmas morning too.

non critical

via MakeUseOf.com https://ift.tt/1AUAxdL

December 21, 2020 at 04:36AM

Memes that made me laugh 37

Memes that made me laugh 37

https://ift.tt/3ax2C4u

 

Harvested over the past week from around the Internet.

And, not funny, but more true than not, IMHO:

True dat.

Peter

non critical

via Bayou Renaissance Man https://ift.tt/1ctARFa

December 21, 2020 at 04:50AM

Laravel Desktop Notifier

Laravel Desktop Notifier

https://ift.tt/3aAnuaT


Laravel Desktop Notifier is a package by Nuno Maduro to send notifications to your desktop from Artisan commands:

public function handle()
{
    $this->notify('Hello Web Artisan', 'Love beautiful code? We do too!');
    // Icons anyone?
    $this->notify(
        'With a logo!',
        'This has a logo',
        resource_path('path/to/icon.png')
    );    
}

The first example would look something like this on macOS:

Under the hood, this package uses the a macro to add the notify method to console commands:

Command::macro('notify', function (string $text, string $body, $icon = null) {
    $notifier = $this->laravel[Contracts\Notifier::class];

    $notification = $this->laravel[Contracts\Notification::class]
        ->setTitle($text)
        ->setBody($body);

    if ( ! empty($icon)) {
        $notification->setIcon($icon);
    }

    $notifier->send($notification);
});

As you can see, the first argument is the notification title, followed by the notification body and the optional icon.

If you’re interested in integrating desktop notifications in a PHP package, this package uses the excellent JoliNotif. Desktop notifications work across Linux, Windows, and macOS!

You can learn more about this package, get full installation instructions, and view the source code on GitHub.

Filed in:
News
/
laravel
/
packages

programming

via Laravel News https://ift.tt/14pzU0d

December 21, 2020 at 09:14AM

2020 Ammo Shortage Rumors Squashed by Ammo Company President

2020 Ammo Shortage Rumors Squashed by Ammo Company President

https://ift.tt/3ph1V3p

(Image: Screenshots from 2020 ammo shortage video)

When it comes to ammo shortages, the USA has seen several in recent years — but 2020’s plethora of panic points has spurred ammo-buyers to new heights of ammo purchasing. And from that comes rumors… ridiculous rumors about the 2020 ammo shortage which can sometimes get out of hand. Some of those rumors include:

  • Ammo is all being stored in secret warehouses instead of being shipped to customers
  • Ammo production has been purposely curtailed in order to hose the public
  • Ammo makers are only selling to certain buyers

Thankfully, such rumors can be squashed by facts, and Vista Outdoors has seen fit to produce a video to address that. In it, we see Jason Vanderbrink, President of Federal, CCI, Speer, and Remington ammunition walking through his manufacturing facilities and telling it like it is. He’s fed up with BS, and I have to say I can’t blame him a bit.

“Hi, I’m Jason Vanderbrink, President of Federal, CCI, Speer, and Remington ammunition, and I gotta say, I am tired of all the hate mail, I’m tired of people showing up at our factories, I’m tired of reading the misinformation out on the internet right now about us not trying to service the demand that we’re experiencing.

“It gets really old when I hear and read constantly that our ammunition companies are not making ammunition, or having secret warehouses, we are selling to only specific customers; and after a year like right now where we have hired hundreds of employees to support American manufacturing jobs, all I hear is, ‘We’re not making ammunition.’”

Vanderbrink cites common sense: 7 million new shooters each buying two 50-round boxes of ammo means that 700 million rounds of ammo are being purchased and consumed by folks who were previously not ammo consumers.

Once you add panic buyers and the vile hoarders to that, you have a recipe for an ammo market that’s low on ammo. And increasing production isn’t like flipping a switch:

  • New people must be hired
  • Those employees must be trained
  • More raw materials must be obtained (lead, copper, brass, gunpowder, etc)
  • All while reconfiguring the factories to comply with new “safety” regulations due to the coronavirus

During the video we see the production lines building, sorting, packing, and shipping ammunition. They’re doing their best to get ammo into your hands and mine.

“I wanted to address those rumors because every day I hear something new — and it’s simply not true.

“We’re making all of the ammunition as fast as we can. We really really feel humble that the demand is high for our products, and I ask: Please squash the rumors. You don’t have to believe everything that’s out in the internet.

“We are doing our damnedest to meet this demand.”

Folks ask where all the 22 ammo has gone; he shows it being made by the hopperful. Ditto 30-06, 9mm Luger, and the list goes on.

Not only are they not slacking off; Vanderbrink says they’re making more ammo than they ever have before in company history.

I like this guy… and I liked him more when I heard his closing words in the video:

“On behalf of our thousands of American manufacturing jobs, thank you for your support, thank you for your patience — and please continue to fight for the Second Amendment that we all so love.”

Please share to squash those groundless rumors about the 2020 ammo shortage.

The post 2020 Ammo Shortage Rumors Squashed by Ammo Company President appeared first on AllOutdoor.com.

guns

via All Outdoor https://ift.tt/2yaNKUu

December 21, 2020 at 11:02AM

Exploring Python’s OS Module

Exploring Python’s OS Module

https://ift.tt/2WtHzrj

Python OS modules allow users to interact with files and directories. There are many functions or methods that Python employs in working with files or directories. However, in this article, we will consider three (3) essential functions. Now, let’s dive straight into it!

Python – os.rename()

Python OS rename() file method renames a file or directory. This method works by passing two arguments named; src (Source) and dst (Destination).

Syntax: 

os.rename(src, dst)

Parameters:

  • Source: This is a path-like object which represents a file system path. It is the target source file path to be renamed.
  • Destination: This is a path-like object which represents a file system path.

Return Type: The os.rename() method does not return any value.

Code 1: How the os.rename() function works

# These codes explain the os.rename() method  
  
# how to import os module  
import os 
  
  
# Source file path 
source = 'Finx/ster.txt'
  
# destination file path 
dest = 'Finx/newster.txt'
  
  
# Using os.rename()method, rename the source path to destination path 
os.rename(source, dest) 
print("Source path successfully renamed to destination path.")

Output:

Source path successfully renamed to destination path

Code #2: How to treat likely errors 

# These codes explain the os.rename() method
  
# how to import os module 
import os 
  
  
# Source file path 
source = './Finx/ster.txt'
  
# destination file path 
dest = './finx/dir'
  
  
# using os.rename()method, attempt renaming src path to dst path
  
try : 
    os.rename(source, dest) 
    print("Source path successfully renamed to destination path.") 
  
# If Source is a file  
# but destination is a directory 
except IsADirectoryError: 
    print("Source is file, but destination is directory.")   
# If source is a directory 
# but destination is a file 
except NotADirectoryError: 
    print("Source is directory, but destination is file.") 
# For permission related errors 
except PermissionError: 
    print("Operation not permitted.") 
  
# For other errors 
except OSError as error: 
    print(error)

Output:

Source is file, but destination is directory

Creating a directory in Python

Python OS Module uses a couple of methods to create a directory. They are : 

  • os.mkdir()
  • os.makedirs()

Using os.mkdir()

Python uses the os.mkdir() method to create a directory known as “path” with the specified numeric mode. If the directory that should be created already exists, os.mkdir() returns FileExistsError message in such situation.

Syntax: 

os.mkdir() and in optional cases the extension – “(path, mode = 0o777, *, dir_fd = None)“ – may be added to the syntax.

Parameter:

  • Path: This is a path-like object which represents a file system path. This path-like object is either a string or bytes object.
  • Mode (optional): This is an integer value which represents the mode of the directory to be created. If this parameter is missing, then the default value: Oo777 is applied.
  • dir_fd (optional): This is a file descriptor referring to a directory. It’s important to note that the default value of this parameter is ‘None’. Please note that dir_fd is ignored, If the specified path is absolute. Please note that the ‘*’ in the parameter list indicates that all following parameters (in this case ‘dir_fd’) are keyword-only.

Return Type: Please note that this method does not return any value

Example #1: How to create a file or directory using the os.mkdir() method

# These codes explain os.mkdir()method 
  
# importing os module 
import os 
  
# Directory 
directory = "Finx"
  
# Parent Directory path 
parent_dir = "D:/Pycharm projects/"
  
# Path 
path = os.path.join(parent_dir, directory) 
  
# Create the directory 
# 'Finxter' in 
# '/home / User / Documents' 
os.mkdir(path) 
print("Directory '% s' created" % directory) 
  
# Directory 
directory = "Finxter"
  
# Parent Directory path 
parent_dir = "D:/Pycharm projects"
  
# mode 
mode = 0o666
  
# Path 
path = os.path.join(parent_dir, directory) 
  
# Create the directory 
# 'Finx' in 
# '/home / User / Documents' 
# with mode 0o666 
os.mkdir(path, mode) 
print("Directory '% s' created" % directory)

Output:

Directory 'Finx' created
Directory 'Finxter' created

Example #2: Likely errors while using the os.mkdir() method.

# These codes explain os.mkdir() method   
      
# importing os module   
import os  
    
# Directory  
directory = "Finx"
    
# Parent Directory path  
parent_dir = "D:/Pycharm projects/"
# Path  
path = os.path.join(parent_dir, directory)      
# Create the directory  
# 'Finx' in  
# '/home / User / Documents'  
os.mkdir(path)  
print("Directory '% s' created" % directory)  
    
# if directory / file that   
# is to be created already  
# exists then 'FileExistsError' message  
# will be returned by os.mkdir() method  
    
# Similarly, if the specified path  
# is invalid 'FileNotFoundError' Error  
# will be flagged

Output:

Traceback (most recent call last):
     File “gfg.py”, line 18, in
         Os.mkdir(path)
FileExistsError: [WinError 183] Cannot create a file when that file /
		      /already exists: ‘D:/Pycharm projects/Finx’

Example #3: How to treat likely errors while using os.mkdir() method.

# These codes explain os.mkdir()method   
      
# importing os module   
import os  
    
# path  
path = 'D:/Pycharm projects / Finx'
    
# Create the directory  
# 'finx' in  
# '/home / User / Documents'  
try:  
    os.mkdir(path)  
except OSError as error:  
    print(error)

How to Check if a File or Directory Exists

Python is a popular, general-purpose, and advanced programming language. It is known to have many functionalities, and one of such functionalities is the ability to check if a file or directory already exists or not. Python performs this task with the help of an in-built os module

With the OS module, Python provides functions needed to interact with the operating system. OS falls under Python’s standard utility modules and those modules provide an efficient way of utilizing operating system dependent functionalities. The os.path module is a submodule of the within Python, used to manipulate common path names.

How to check if a file exists already

The os.path.isfile() method checks whether the specified path is an existing file or not. Please note that os.path.isfile() follows symlinks.

Syntax: os.path.isfile(path)

Parameter:

  • Path: This is a path-like object which represents a file system path. This path-like object is either a string or bytes object.

Return Type: This method returns a Boolean value. it returns ‘True’ if the specified path is an existing file. Otherwise, it returns ‘False’.

Example:

# These codes explain os.path.isfile() method   
      
# importing os module   
import os  
    
# Path  
path = 'D:/Pycharm projects/Finx/vos/quiz_vos.txt'
    
# Check whether the   
# specified path is   
# an existing file  
isFile = os.path.isfile(path)  
print(isFile) 
    
    
# Path  
path = 'D:/Pycharm projects/Finx/vos/'    
# Check whether the   
# specified path is   
# an existing file  
isFile = os.path.isfile(path)  
print(isFile)

Output:

True
False

How to check if a directory exists

Python uses the os.path.isdir() method to check whether a specified path is an existing directory or not. This method follows a symbolic link, which means if the specified path is a symbolic link pointing to a directory, then the process returns ‘True’.

Syntax: os.path.isdir(path)

Parameter:

  • Path: This is a path-like object which represents a file system path.

Return Type: This method returns a Boolean value. This method returns ‘True’ if the specified path is an existing directory. Otherwise, it returns ‘False’.

Example #1: How to use the os.path.isdir() method.

# These codes explain os.path.isdir() method   
      
# importing os.path module   
import os.path  
    
# Path  
path = 'D:/Pycharm projects/Finx/vos/quiz_vos.txt'
    
# Check whether the   
# specified path is an  
# existing directory or not  
isdir = os.path.isdir(path)  
print(isdir)  

# Path  
path = 'D:/Pycharm projects/Finx/vos/'
    
# Check whether the   
# specified path is an  
# existing directory or not  
isdir = os.path.isdir(path)  
print(isdir) 

Output:

False
True

Example #2: What happens if the specified path is a symbolic link?

# These codes explain os.path.isdir() method.   
      
# importing os.path module.   
import os.path  
    
    
# Create a directory(in current working directory).  
dirname = "Finx"
os.mkdir(dirname)  
    
# Create a symbolic link pointing to the above directory.  
symlink_path = "D:/Pycharm projects/Finx/vos/"
os.symlink(dirname, symlink_path)  
        
path = dirname  
    
# Investigate if the specified path is an existing directory or not.  
isdir = os.path.isdir(path)  
print(isdir)  
    
path = symlink_path  
    
# Check whether the specified path - a symbolic link - is an  
# existing directory or not.  
isdir = os.path.isdir(path)  
print(isdir)

Output:

True
True

How to check if either file or directory exists

Python uses the os.path.exists() method to check whether a specified path exists or not. This method also checks if the given path refers to an open file descriptor or not. The method checks if either a file or directory exist.

Syntax: os.path.exists(path)

Parameter:
Path:
 This is a path-like object which represents a file system path. This path-like object is either a string or bytes object.

Return Type: This method returns a Boolean value. The os.path.exists() method returns ‘True’, if the path exists. Otherwise, it returns ‘False’.

Example:

# These codes explain os.path.exists() method   
       
# importing os module   
import os  
     
# Path  
path = 'D:/Pycharm projects/Finx/vos/quiz_vos.txt'
     
# Find out if the specified path is an existing file.  
isExist = os.path.exists(path)  
print(isExist) 
         
# Path  
path = 'D:/Pycharm projects/Finx/vos/'
     
# Finally, check if the specified path is an existing file.  
isExist = os.path.exists(path)  
print(isExist)

Output:

True
True

Please note that even if the path exists, the os.path.exists() function may still return ‘False’, if the execution of os.stat() is not authorized.

To learn more about Python, become a Finxter Scholar. Join here https://blog.finxter.com/email-academy/ now!

Reference

The post Exploring Python’s OS Module first appeared on Finxter.

Python

via Finxter https://ift.tt/2HRc2LV

December 20, 2020 at 09:29AM