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
Spire.PDF for Java 2.7.8
Database Workbench Pro 5.6.10.0
The C# PDF Library 2020.1.5
CAD-Viewer 3DVBVIEW V4
dotConnect for SQLite 5.15
LuaStudio 9.92
EntityDAC 2.3
Devart ODBC Driver for QuickBooks 2.0
phpEnter 5.1.
Udemy Clone script 2.01
VisualNEO Web 19.11.7
VisualNEO for Windows 19.4.29.0
SentiVeillance SDK Trial 7.3
Devart ODBC Driver for PostgreSQL 3.2
SecureBridge 9.2
Top Code
SecureBridge 8.0
dotConnect for SQLite 5.9
EntityDAC 1.6
Database Workbench Pro 5.6.10.0
ATN Site Builder 3.0
ATN Resume Finder 2.0
The C# PDF Library 1.0
SentiVeillance SDK Trial 7.3
PHP Review Script 1.0
ICPennyBid Penny Auction Script 4.0
Invoice Manager by PHPJabbers 3.0
Devart ODBC Driver for PostgreSQL 3.2
ADO.NET Provider for ExactTarget 1.0
Deals and Discounts Website Script 1.0.2
Aglowsoft SQL Query Tools 8.2
Top Rated
phpEnter 5.1.
Single Leg MLM 1.2.1
Azizi search engine script PHP 4.1.10
Paste phpSoftPro 1.4.1
Extreme Injector 3.7
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
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