Search
Code Directory
 ASP
 ASP.NET
 C/C++
 CFML
 CGI/PERL
 Delphi
 Development
 Flash
 HTML
 Java
 JavaScript
 Pascal
 PHP
 Python
 SQL
 Tools
 Visual Basic & VB.NET
 XML
New Code
C# QR Code Generator 4.0.2.2
Salesforce WordPress Customer Portal 3.2.0
Single Leg MLM 1.2.1
OzGIS 14.6
Quick Maps For Dynamics CRM 3.1
Job Board Software 4.2
PHP Real Estate Script 1.3.2
IP2Location Geolocation Database April.2019
dbForge Data Generator for Oracle 2.1
VisualNEO Web 2018.12.15
SentiMask SDK Trial 1.0.0
OrgChart JS 4.6.4
dotConnect for BigCommerce 1.8
FedEx Smart Shipping For Magento 1.0.0
Database Workbench Pro 5.6.2.311
Top Code
C++ Math Helper Class 1.0
Circle Fit (Taubin method) 1.0
Bullshit Bingo 1.0
unluac 1.0
RzLabel
PHPMaker 10.0
ClearImage Barcode 1D Pro 5.0
Pig Latin 0.1
Karamasoft UltimateCalendar 1.1
Rapid PHP Editor 2011 11.3
CodeX Barcode Control for .NET V1.0.0
MP3 Converter 2.68
Rapid CSS Editor 2005 6.02
ClearImage Barcode SDK 7.0
Top Rated
VisualNEO Web 2018.12.15
Paste phpSoftPro 1.4.1
Deals and Discounts Website Script 1.0.2
ADO.NET Provider for ExactTarget 1.0
Solid File System OS edition 5.1
Classified Ad Lister 1.0
Aglowsoft SQL Query Tools 8.2
Invoice Manager by PHPJabbers 3.0
ICPennyBid Penny Auction Script 4.0
PHP Review Script 1.0
ATN Resume Finder 2.0
ATN Site Builder 3.0
Availability Booking Calendar PHP 1.0
PHP GZ Blog Script 1.1
ATN Jobs Software 4.0
dealing with directory paths with ~ 
File ID: 64704






dealing with directory paths with ~ 
Download dealing with directory paths with ~ http://code.activestate.com/recipes/577270-dealing-with-directory-paths-with/?in=lang-pythonReport Error Link
License: Freeware
Downloads: 1
Submit Rating:
dealing with directory paths with ~  Description
Description: Dealing with directory paths which start with ~ which are passed as paramaters, to os module functions.

Here is what I think python doesn't do for me:

>>> import os
# suppose my home = curdir = /home/rv
>>> os.path.abspath('.')
'/home/rv'

Now if I want to go to folder /home/rv/test if there is no folder by name
/home/rv/~/test/

# This is what happens by default.
>>> os.path.abspath('~/test')
'/home/rv/~/test'

>>> os.chdir('/home/rv/some/dir')
# doesn't matter if the resulting path exists or not.
>>> os.path.abspath('~/test')
'home/rv/some/dir/~/test'

This would be more sensible I guess:

# if /home/rv/~/test doesn't exist
>>> os.path.abspath('~/test')
'/home/rv/test'

License: Freeware

Related: Directory, expanding, paths

O/S:Windows

Downloads: 1



More Similar Code

When dealing with windows paths on a *nix system sometimes youll need to resolve case insensitive paths. While using a fat filesystem or making everything lowercase would work.
this function means you can get python to take a case insensitive path and return the path with the correct case (if it exists).



Dealing with DllImport is an easy to understand tutorial in which the author gives description about basic concepts of DLLimport attribute for importing DLL functionalities to perform particluar task. The author explains about...



While dealing with paths, it's often necessary to make sure they all have the same structure so any operation you perform on them can be reliable, specially when it comes to comparing two or more paths. Unusual paths like...



The m-files in this directory are used to create a draw-program-like interface for dealing with MATLAB graphs. When you type 'matdraw' at the MATLAB prompt, they will create a palette with some standard draw tools and a suite of menus with a...



Although many Perl modules dealing with various aspects of XML (among which a good number offer various ways of transforming XML documents), other languages seem to be favored by XML developers for example, Java, C/C++, and maybe even Python. Sun,...



You run this script with directory as parameter (defaults to current directory) and scripts watch this directory for changes in files - creating new file, deleting some file and modification to any file. All these changes are periodically commited...



This is a set of classes I have used for dealing with URL parsing in an easy and convenient manner. It keeps the code clean, etc.



A common practice when dealing with sequences is to find the first or last item in the list that satisfies a predicate. This simple recipe increases the readability and writability for these tasks and nothing more.



Orderific is a Ruby on Rails plugin that makes dealing with ActiveRecord :order clauses easier.



Spockets is a simple library for dealing with multiple sockets. Supply a socket, and one or more blocks to execute, and Spockets will make sure those blocks get executed when something comes in over the wire using an ActionPool for efficient...

User Review for dealing with directory paths with ~
- required fields
     

Please enter text on the image