what are the simple ways?
I could think of os.open(), os.exec(touch file)
are there any simpler methods? 8 16180
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: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM).
In this month's session, the creator of the excellent VBE...
|
by: MeoLessi9 |
last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
|
by: DolphinDB |
last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation.
Take...
|
by: Aftab Ahmad |
last post by:
Hello Experts!
I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
|
by: Aftab Ahmad |
last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below.
Dim IE As Object
Set IE =...
|
by: marcoviolo |
last post by:
Dear all,
I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
| |