Does anybody know of a list for canonical prefixes to use for hungarian
notation in Python? Not that I plan to name all my variables with hungarian
notation, but just for when it's appropriate. 12 3596
inhahe wrote:
Does anybody know of a list for canonical prefixes to use for hungarian
notation in Python? Not that I plan to name all my variables with hungarian
notation, but just for when it's appropriate.
I used simple Hungarian notation when I started programming in Python
(e.g. "s" for strings, "l" for lists, "d" for dictionaries). As my
programming style became more "Pythonic" and I chose better variable
names, I stopped using Hungarian notation.
YMMV.
--
Kam-Hung Soh <a href="http://kamhungsoh.com/blog">Software Salariman</a>
On May 27, 12:28*am, "inhahe" <inh...@gmail.c omwrote:
Does anybody know of a list for canonical prefixes to use for hungarian
notation in Python? *Not that I plan to name all my variables with hungarian notation, but just for when it's appropriate.
You are likely to get some links to PEP 8 for coding style and naming
conventions, but it turns out PEP 8 doesn't really say yay or nay on
the Hungarian notation topic.
My own knee-jerk reaction was "Hungarian Notation Bad!" and googling
about for "python hungarian notation" led me through some like-minded
sites. But I also found this entry on Joel Spolky's site (http:// http://www.joelonsoftware.com/printe...es/Wrong.html), that
warns against tarring all Hungarian-type notations with the same
brush.
So with that article in mind, I'd have to ask, what do you mean by
"appropriat e"?
-- Paul
Well, I just need it once in a while. Actually now is the only time I
remember. The last time what I needed was a file name extension. I want a
string called headers, but I want to derive a dict from it, also called
headers. So I figured the string would be called strHeaders, and the dict,
dctHeaders probably, but when a precedent for something like that exists, I
like to use it.
"Kam-Hung Soh" <ka*********@gm ail.comwrote in message
news:ma******** *************** *************** *@python.org...
inhahe wrote:
>Does anybody know of a list for canonical prefixes to use for hungarian notation in Python? Not that I plan to name all my variables with hungarian notation, but just for when it's appropriate.
I used simple Hungarian notation when I started programming in Python
(e.g. "s" for strings, "l" for lists, "d" for dictionaries). As my
programming style became more "Pythonic" and I chose better variable
names, I stopped using Hungarian notation.
YMMV.
--
Kam-Hung Soh <a href="http://kamhungsoh.com/blog">Software Salariman</a>
On May 27, 2:42 am, "inhahe" <inh...@gmail.c omwrote:
Well, I just need it once in a while. Actually now is the only time I
remember. The last time what I needed was a file name extension. I want a
string called headers, but I want to derive a dict from it, also called
headers. So I figured the string would be called strHeaders, and the dict,
dctHeaders probably, but when a precedent for something like that exists, I
like to use it.
I doubt there's anything canonical since Python community, PEP 8, and
Python's dynamic typing all discourage its use. I would venture to
say that the community would frown upon names such as "strHeaders "
since they don't agree with the naming conventions in PEP 8. Instead,
use "str_header s" and "dict_heade rs". Better yet, use "headers_st r"
and "headers_di ct". Put the less important information last.
Carl Banks
On May 27, 2:37 am, Paul McGuire <pt...@austin.r r.comwrote:
On May 27, 12:28 am, "inhahe" <inh...@gmail.c omwrote:
Does anybody know of a list for canonical prefixes to use for hungarian
notation in Python? Not that I plan to name all my variables with hungarian notation, but just for when it's appropriate.
You are likely to get some links to PEP 8 for coding style and naming
conventions, but it turns out PEP 8 doesn't really say yay or nay on
the Hungarian notation topic.
My own knee-jerk reaction was "Hungarian Notation Bad!" and googling
about for "python hungarian notation" led me through some like-minded
sites. But I also found this entry on Joel Spolky's site (http://www.joelonsoftware.com/printe...es/Wrong.html), that
warns against tarring all Hungarian-type notations with the same
brush.
The name of a variable is a valuable resource. There are all kinds of
things you can encode in it, but you have to choose only one or two.
The most important information is what it is (e.g., box), or what it's
archetype is (i, for a counter variable). Pretty much all names
should contain one of these two. Second most important are
discriminators such as a description (red_box), usage (shoebox), or
circumstance (next_box).
But sometimes other things are important enough to warrant addition to
the name. Type usually isn't one of them, but there are times when
it's helpful to know. But then, I'm not sure I would call it
"Hungarian notation" to add ad hoc type information to a few of names
here and there.
One convention I have for myself is to use x<elementnamefo r elements
when I'm using ElementTree, but the reason is pragmatic: I'm creating
objects that have the same name as the elements.
So with that article in mind, I'd have to ask, what do you mean by
"appropriat e"?
It seems like OP wanted to disambiguate two objects based on type,
which seems reasonable to me. Sometimes you want to have side-by-side
represenations of something where type is the main difference, in
which case there's no reason type shouldn't be added to the name.
Carl Banks
On May 27, 7:42 am, "inhahe" <inh...@gmail.c omwrote:
Well, I just need it once in a while. Actually now is the only time I
remember. The last time what I needed was a file name extension. I want a
string called headers, but I want to derive a dict from it, also called
headers. So I figured the string would be called strHeaders, and the dict,
dctHeaders probably, but when a precedent for something like that exists, I
like to use it.
"Kam-Hung Soh" <kamhung....@gm ail.comwrote in message
I have a my own sometime used convention od using dict names that
mirror
what is being mapped to what, so a dict mapping headers to body might
be called head2body, in general a mapping from x to y I might call
x2y.
- Paddy.
"Paul McGuire" <pt***@austin.r r.comwrote in message
news:74******** *************** ***********@8g2 000hse.googlegr oups.com...
On May 27, 12:28 am, "inhahe" <inh...@gmail.c omwrote:
My own knee-jerk reaction was "Hungarian Notation Bad!" and googling
about for "python hungarian notation" led me through some like-minded
sites. But I also found this entry on Joel Spolky's site (http:// http://www.joelonsoftware.com/printe...es/Wrong.html), that
warns against tarring all Hungarian-type notations with the same
brush.
Wow, that was fascinating. I had no idea Hungarian notation originally
didn't mean to prefix the object type!
On May 27, 3:43 am, Paddy <paddy3...@goog lemail.comwrote :
On May 27, 7:42 am, "inhahe" <inh...@gmail.c omwrote:
Well, I just need it once in a while. Actually now is the only time I
remember. The last time what I needed was a file name extension. I want a
string called headers, but I want to derive a dict from it, also called
headers. So I figured the string would be called strHeaders, and the dict,
dctHeaders probably, but when a precedent for something like that exists, I
like to use it.
"Kam-Hung Soh" <kamhung....@gm ail.comwrote in message
I have a my own sometime used convention od using dict names that
mirror
what is being mapped to what, so a dict mapping headers to body might
be called head2body, in general a mapping from x to y I might call
x2y.
I use the same convention, though it's less than ideal if x or y
consist of more than one word (typically joined with underscore), e.g.
"value2row_ id" or if the values are also dicts
("category2valu e2instances").
George
On May 27, 12:28*am, "inhahe" <inh...@gmail.c omwrote:
Does anybody know of a list for canonical prefixes to use for hungarian
notation in Python? *Not that I plan to name all my variables with hungarian
notation, but just for when it's appropriate.
pnWe vUse adjHungarian nNotation prepAt nWork, conjAnd pnI vauxDont
vLike pnIt advVery advMuch. conjSo pnI vAvoid pnIt prepIn nPython. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Phill |
last post by:
Does anyone know the reasoning for Microsoft abandoning Hungarina
Notation in C#?
I have found it very usefull in C++. I like this style:
constant: MY_CONSTANT
methos: myMethod()
class: MyClass
variable: iMyInteger
|
by: CMM |
last post by:
So after three years of working in .NET and stubbornly holding on to my old
hungarian notation practices--- I resolved to try to rid myself of the
habit. Man, I gotta say that it is liberating!!! I love it.
At first I struggled with how to name controls. I tried to keep some sort of
notation with them... but I threw that away too!!! I now name them as if
they were simply properties of the form (FirstNameLabel, etc.)... which they
ARE!......
|
by: Ronald S. Cook |
last post by:
I've been weaning myself off of Hungarian notation because that's what
Microsoft is telling me to do, and I want to be a good little MS developer.
But things keep coming up that make me miss my little 3-character prefixes.
I'm fine with EmployeeFirstNameLabel instead of lblEmployeeFirstName, but at
the table and class level, I get frustrated because terms I want to use
reserved keywords.
I wanted "Event" and "User" as classes and table...
|
by: dom.k.black |
last post by:
I am looking at starting a new piece of work for a company who are
heavily into hungarian notation for C coding.
Any killer arguments for NOT carrying this terrible practice forward
into new C++ code?
|
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:
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
| |
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
| |