what are the simple ways?
I could think of os.open(), os.exec(touch file)
are there any simpler methods? 8 16187
On 22 Mag, 01:15, Nikhil <mnik...@gmail.comwrote:
what are the simple ways?
I could think of os.open(), os.exec(touch file)
are there any simpler methods?
Just use os.path.exists to check for file existence and open() as
replacement for touch.
>>import os if not os.path.exists('file'):
.... open('file', 'w').close()
....
>>>
--- Giampaolo http://code.google.com/p/pyftpdlib/
On May 21, 5:10 pm, "Giampaolo Rodola'" <gne...@gmail.comwrote:
On 22 Mag, 01:15, Nikhil <mnik...@gmail.comwrote:
what are the simple ways?
I could think of os.open(), os.exec(touch file)
are there any simpler methods?
Just use os.path.exists to check for file existence and open() as
replacement for touch.
>import os if not os.path.exists('file'):
... open('file', 'w').close()
...
--- Giampaolohttp://code.google.com/p/pyftpdlib/
As simple as it gets is a single builtin function call:
open("somefile.txt", "a")
Leave out the ,"a" if you don't mind blanking a pre-existing file.
bukzor wrote:
On May 21, 5:10 pm, "Giampaolo Rodola'" <gne...@gmail.comwrote:
>On 22 Mag, 01:15, Nikhil <mnik...@gmail.comwrote:
>>what are the simple ways? I could think of os.open(), os.exec(touch file) are there any simpler methods?
Just use os.path.exists to check for file existence and open() as replacement for touch.
>>>>import os if not os.path.exists('file'):
... open('file', 'w').close() ... --- Giampaolohttp://code.google.com/p/pyftpdlib/
As simple as it gets is a single builtin function call:
open("somefile.txt", "a")
Leave out the ,"a" if you don't mind blanking a pre-existing file.
Thanks :-)
That reminds me to check if I could quickly nullify a file if it exists
if os.path.exists('file'):
open('file', 'w').close()
Right?
On May 21, 5:37 pm, Nikhil <mnik...@gmail.comwrote:
bukzor wrote:
On May 21, 5:10 pm, "Giampaolo Rodola'" <gne...@gmail.comwrote:
On 22 Mag, 01:15, Nikhil <mnik...@gmail.comwrote:
>what are the simple ways? I could think of os.open(), os.exec(touch file) are there any simpler methods?
Just use os.path.exists to check for file existence and open() as
replacement for touch.
>>>import os if not os.path.exists('file'):
... open('file', 'w').close()
...
--- Giampaolohttp://code.google.com/p/pyftpdlib/
As simple as it gets is a single builtin function call:
open("somefile.txt", "a")
Leave out the ,"a" if you don't mind blanking a pre-existing file.
Thanks :-)
That reminds me to check if I could quickly nullify a file if it exists
if os.path.exists('file'):
open('file', 'w').close()
Right?
You only want to blank it if it exists? If it doesn't exist you won't
create it.
The .close() is superlative: since you don't keep the value, it gets
deallocated and closed by the destructor.
On Wed, 21 May 2008 17:56:38 -0700, bukzor wrote:
On May 21, 5:37 pm, Nikhil <mnik...@gmail.comwrote:
>if os.path.exists('file'): open('file', 'w').close()
Right?
You only want to blank it if it exists? If it doesn't exist you won't
create it.
The .close() is superlative: since you don't keep the value, it gets
deallocated and closed by the destructor.
The language neither guarantees *when* an object will be deallocated nor
that its destructor is called *at all*. It's cleaner to explicitly close
the file.
Ciao,
Marc 'BlackJack' Rintsch
After os.path.exists, you need to check it _is_ a
file, and not a directory.
Giampaolo Rodola' wrote:
On 22 Mag, 01:15, Nikhil <mnik...@gmail.comwrote:
>what are the simple ways? I could think of os.open(), os.exec(touch file)
are there any simpler methods?
Just use os.path.exists to check for file existence and open() as
replacement for touch.
>>>import os if not os.path.exists('file'):
... open('file', 'w').close()
...
--- Giampaolo http://code.google.com/p/pyftpdlib/
On 22 Mag, 11:54, Ken Starks <stra...@lampsacos.demon.co.ukwrote:
After os.path.exists, you need to check it _is_ a
file, and not a directory.
Giampaolo Rodola' wrote:
On 22 Mag, 01:15, Nikhil <mnik...@gmail.comwrote:
what are the simple ways?
I could think of os.open(), os.exec(touch file)
are there any simpler methods?
Just use os.path.exists to check for file existence and open() as
replacement for touch.
>>import os if not os.path.exists('file'):
... * * open('file', 'w').close()
...
--- Giampaolo http://code.google.com/p/pyftpdlib/- Nascondi testo tra virgolette -
- Mostra testo tra virgolette -
Yeah, I forgot. :\
--- Giampaolo http://code.google.com/p/pyftpdlib
On May 22, 12:07 am, Marc 'BlackJack' Rintsch <bj_...@gmx.netwrote:
On Wed, 21 May 2008 17:56:38 -0700, bukzor wrote:
On May 21, 5:37 pm, Nikhil <mnik...@gmail.comwrote:
if os.path.exists('file'):
open('file', 'w').close()
Right?
You only want to blank it if it exists? If it doesn't exist you won't
create it.
The .close() is superlative: since you don't keep the value, it gets
deallocated and closed by the destructor.
The language neither guarantees *when* an object will be deallocated nor
that its destructor is called *at all*. It's cleaner to explicitly close
the file.
Ciao,
Marc 'BlackJack' Rintsch
Good to know. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: pekka niiranen |
last post by:
Does anybody know Python recipe for changing the date
of the directory or files in W2K to current date and time?
In UNIX shell command "touch" does it.
-pekka-
|
by: Robert May |
last post by:
I have an application that processes text strings using information in a
file. I want to deploy this app using no-touch deployment. The config
files and everything else are deployed just fine,...
|
by: Marek |
last post by:
Hi there,
my WinForm application has to be installed in "no-touch-deployment" mode, so
users can run it from the web. I need to read application's .config file but
it does not work in ...
|
by: John Ross |
last post by:
Enterprise Library - No Touch Deployment:
I have used this website and I cannot get to it.
http://blog.hishambaz.com/archive/2005/01/29/194.aspx
Invalid section name. The section...
|
by: James |
last post by:
I have a VB windows forms application that accesses a Microsoft Access
database that has been secured using user-level security. The
application is being deployed using No-Touch deployment. The...
|
by: James |
last post by:
I have a VB windows forms application that accesses a Microsoft Access
database that has been secured using user-level security. The
application is being deployed using No-Touch deployment. The...
|
by: Giancarlo Berenz |
last post by:
Hi:
Recently i write this code:
class Simple
{
private:
int value;
public:
int GiveMeARandom(void);
|
by: Chuck Anderson |
last post by:
I've got a script that "syncs" files from my working hard drive (Windows
XP) to a backup drive based on filesize and filemtime. It's never had
problems at the DST switch before, but since...
|
by: myself337 |
last post by:
in VB you can do this:
Imports System
Imports System.IO
Module Module1
Sub Main()
Dim path As String = "c:\temp\filetocopy.txt" ' put the file you
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |