I looked in the language but did not find a switch for requiring
variables to be declared before use.
Is such an option available?
Thanks,
jvh 8 3406
On 2007-05-16, HMS Surprise <jo**@datavoice int.comwrote:
I looked in the language but did not find a switch for requiring
variables to be declared before use.
Still trying to write Pascal, eh? ;)
Is such an option available?
No.
However, there are utilities to "proofread" your code should
you have a desire for that: http://www.logilab.org/pylint http://pychecker.sourceforge.net/
--
Grant Edwards grante Yow! What I need is a
at MATURE RELATIONSHIP with a
visi.com FLOPPY DISK ...
No haven't had to endure Pascal. Mostly C/C++, Tcl, and assembler. Oh
yeah, and a (thankfully) short stint of Ada.
But I glad to hear of the proofing tools. Working a lot of data parsed
from web pages and the developer there a different naming convention
from what I am accustomed so sometimes I introduce a new variable
unintentionally .
Thanks,
jvh
On May 16, 9:57 am, HMS Surprise <j...@datavoice int.comwrote:
I looked in the language but did not find a switch for requiring
variables to be declared before use.
Is such an option available?
Thanks,
jvh
You do have to declare a variable before use. You do so by assigning
it a value. You can't use a variable before it has been assigned. In
some ways this is less ambiguous than even C where you can declare a
variable without assigning a value. Also note that this caries the
type information, since the variable is of whatever type was assigned
to it. The only thing it doesn't do is give a unique flag that says
"hey this is where I'm declared", although I suppose you could do that
with a comment.
Matt
Matimus wrote:
On May 16, 9:57 am, HMS Surprise <j...@datavoice int.comwrote:
>I looked in the language but did not find a switch for requiring variables to be declared before use.
Is such an option available?
Thanks,
jvh
You do have to declare a variable before use. You do so by assigning
it a value. You can't use a variable before it has been assigned. In
some ways this is less ambiguous than even C where you can declare a
variable without assigning a value. Also note that this caries the
type information, since the variable is of whatever type was assigned
to it. The only thing it doesn't do is give a unique flag that says
"hey this is where I'm declared", although I suppose you could do that
with a comment.
Strictly, the variable has no type at all (and strictly your "variables"
are actually names bound to values in a namespace, and it's the values
that are typed).
We shouldn't ignore the fact that declarations unambiguously say "the
programmer intends to use such-and-such a name for a value of a specific
type". Contrast this with a Python program where one path makes an
assignment (binding) to a name while another path doesn't, resulting in
a later NameError.
regards
Steve
--
Steve Holden +1 571 484 6266 +1 800 494 3119
Holden Web LLC/Ltd http://www.holdenweb.com
Skype: holdenweb http://del.icio.us/steve.holden
------------------ Asciimercial ---------------------
Get on the web: Blog, lens and tag your way to fame!!
holdenweb.blogs pot.com squidoo.com/pythonology
tagged items: del.icio.us/steve.holden/python
All these services currently offer free registration!
-------------- Thank You for Reading ----------------
On May 16, 6:48 pm, Matimus <mccre...@gmail .comwrote:
On May 16, 9:57 am, HMS Surprise <j...@datavoice int.comwrote:
I looked in the language but did not find a switch for requiring
variables to be declared before use.
Is such an option available?
Thanks,
jvh
You do have to declare a variable before use. You do so by assigning
it a value. You can't use a variable before it has been assigned.
Yes this is where the problem arises. This is a gross
oversimplificat ion , but is where I typically find problems.
jh
#~~~~~~~~~~~~~~ ~~~~~~~~
createdIncident Id = 0
..
..
..
#attempt to change varialbe
createdIncident ID = 1
..
..
..
if createdIncident Id == 1:
...
HMS Surprise schrieb:
>
#~~~~~~~~~~~~~~ ~~~~~~~~
createdIncident Id = 0
.
.
.
#attempt to change varialbe
createdIncident ID = 1
.
.
.
if createdIncident Id == 1:
...
test.py is your code above
$ pychecker -v test.py
Processing test...
Warnings...
test.py:7: Variable (createdInciden tID) not used
Gregor
On 2007-05-16, HMS Surprise <jo**@datavoice int.comwrote:
No haven't had to endure Pascal. Mostly C/C++, Tcl, and assembler.
I must have you mixed up with somebody else who recently
mentioned having Pascal as their first real language.
--
Grant Edwards grante Yow! It's OKAY -- I'm an
at INTELLECTUAL, too.
visi.com
On May 17, 9:34 am, Grant Edwards <gra...@visi.co mwrote:
On 2007-05-16, HMS Surprise <j...@datavoice int.comwrote:
No haven't had to endure Pascal. Mostly C/C++, Tcl, and assembler.
I must have you mixed up with somebody else who recently
mentioned having Pascal as their first real language.
--
Grant Edwards grante Yow! It's OKAY -- I'm an
at INTELLECTUAL, too.
visi.com
That's OK. I am easily mixed up. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Stefanie |
last post by:
Hi,
I have a question about declaring variables for writing data to a file for
random access.
I have two string variables declared in a module (user-defined types).
The point is that for one of them i can't define (hard coded) a fixed
length because the application is reading data
from another file (In that file they have the same lenght).
Is it possible to use the lenght i obtain from reading that other file to
declare my variable or...
|
by: Oliver Corona |
last post by:
I am wondering if anyone has any insights on the performance benefit (or
detriment) of declaring local variables instead of referencing members.
Is allocating memory for a new variable more efficient than repeatedly
referencing the member in a loop?
Maybe using a string isn't the best example, but hopefully you get the
idea!
* example (referencing member):
|
by: ross.oneill |
last post by:
Hi,
I am having trouble with a simple task of declaring a variable. Is
this possible?
Here is what I want to do.
DECLARE start_date date;
DECLARE end_date date;
SET start_date = '2005-01-01'
|
by: ColinWard |
last post by:
Hi guys.
I have a question about declaring variables. I do a lot of re-querying
of controls in my database and I use the Set statement with a variable
set to the name of the control to tell the program which control to
requery. This makes it easy to requery controls on a different form.
However, up until today, I was dimming a new local variable for each
control I wanted to deal with ( E.G. Dim cbxctl as control) and then
setting that...
|
by: param |
last post by:
Declaring struct as static is creating problem with newer version of CC
compiler 5.7 in solaris.
e.g.
static struct new_str {
int a;
int b;
};
| |
by: Mark A. Sam |
last post by:
Hello,
I am using Visual Web Developer 2005 Express. I want to declare a varible,
using Visual Basic as the language and can't get anywhere. For example
Public Test1 as String
I'll get en error saying to change Public to Dim. When I do, it will say
that Test1 is an unused local variable.
|
by: jbeteta |
last post by:
Hello,
I have a problem declaring variables. I need to create an object oRpte
as ReportClass on WebForm1.aspx and be able to use its value on
WebForm2.aspx.
For declaring the property oRpte() on WebForm1.aspx, I use "Public
Property" and I declare variable _oRpte as Friend Shared. That's my
problem. If I don't declare _oRpte as Friend Shared, I can't use
WebForm1.oRpte() on other webpage. If I declare _oRpte as Friend
Shared, I can use...
|
by: TARUN |
last post by:
I have a question about declaring the Global.ascx:
In VS.NET I create a Solution, and there are 4 projects under it. They
are put under 4 folders, but web pages would be called across the 4
projects. For example, web page Page1 in Project1 will redirect to web
page Page2 in Project2 which will further redirect to Page3 in
project3 and Page4 in Project4 and finally back to Page1.
In each web page, some session variables, such as...
|
by: SM |
last post by:
I've always wonder if there is diference when declaring and
initializing a varible inside/outside a loop.
What's a better practice?
Declaring and initializing variables inside a loop routine, like this:
for(var i=0; i<list; i++)
{
var name = list;
}
|
by: =?Utf-8?B?QUw=?= |
last post by:
Hi
I usually stick to the convention of not declaring variables in my bodies of
"loops" (including foreach)
ie
int x;
for (int i = 0; i < 10; i++) {
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |