473,395 Members | 1,521 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Using open() inside a subroutine

Whenever I try to open a file inside a subroutine, like so:

def open():
filePath=askopenfilename()

fileOpen = open(filePath, "r")
fileContent = fileOpen.read()
fileOpen.close()

it tells me that "open() takes no arguments (2 given)"
Why is that? and how can I get around that so I can open a file in a
subroutine?

Thanks,
Alex

Jul 18 '05 #1
2 1231
On 2005-02-18, imphasing <al**@fortworks.com> wrote:
Whenever I try to open a file inside a subroutine, like so:

def open():
filePath=askopenfilename()

fileOpen = open(filePath, "r")
fileContent = fileOpen.read()
fileOpen.close()

it tells me that "open() takes no arguments (2 given)"
Why is that?
Because you defined open() as taking no arguments. You're
calling your own open() function, not the builtin one.
and how can I get around that so I can open a file in a
subroutine?


Don't call your function open().

--
Grant Edwards grante Yow! Th' MIND is the Pizza
at Palace of th' SOUL
visi.com
Jul 18 '05 #2
DUH. Thanks.
can't beleive I missed that one...

Alex

Jul 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Santosh | last post by:
Hello all, I am trying to interface c++ and fortran, the fortran code is already there and I was successful in calling the subroutines and functions, but was not able to send the fortran module...
4
by: banz | last post by:
Hello I have a problem to resolve: I wrote a Perlscript which caches data from a server (local on my machine) I would like to have a other connection to a remote server but I don't know how to...
7
by: | last post by:
Hello, I would like to do the following from a asp.net button click: <form method="POST" action="https://www.1234.com/trans_center/gateway/direct.cgi"> <input type="hidden" name="Merchant"...
0
by: comtrendz | last post by:
Hi members, I'm new to .Net. soplease be patient... I am writing a User Interface for a Medical practice where they want the ability to display 4 picture on one form. No problems so far. These...
21
KevinADC
by: KevinADC | last post by:
Note: You may skip to the end of the article if all you want is the perl code. Introduction Uploading files from a local computer to a remote web server has many useful purposes, the most...
0
by: Blaine | last post by:
Hello, Can anyone provide me with a simple example of the following: 1.) Writing a COM interface for a subroutine placed inside a "Class Library" project using vb 2008 express edition. I want...
8
by: Lynn McGuire | last post by:
Can I use a function argument as an array limit in a another argument ? Such as: int myFunction (int ncp, double myArray ); and int myFunction (int * ncp, double myArray ); Thanks,
4
by: pavanponnapalli | last post by:
hi, I need to send some values to a subroutine where i use insert query. suppose say my scalar is as follows: my ($name,$number,$address) etc and i get the values into those...
2
by: jim190 | last post by:
I am relatively new to using VBA and am have been trying for two days to pass a user entered value to my report for filtering when opened. I have the following subroutine in the open event of my...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
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...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.