I use generators a lot. E.g.
def gen_words(text)
... parse text ...
yield each word in text
for word in gen_words(text):
print word
I don't like the name gen_xxx() very much. Looking for some inspiration
to name generators. Here are some of my ideas:
enumerate_words
gen_words
generate_words
parse_words
walk_words
Any idea? Do you have a naming convention for generators?
wy 5 7727 au******@gmail.com schrieb: I use generators a lot. E.g.
def gen_words(text) ... parse text ... yield each word in text
for word in gen_words(text): print word
I don't like the name gen_xxx() very much. Looking for some inspiration to name generators. Here are some of my ideas:
enumerate_words gen_words generate_words parse_words walk_words
Any idea? Do you have a naming convention for generators?
No. From my POV, a generator is not different from any other method
returning a list. I don't care if the implementation is
def words():
return ["dies", "ist", "das", "Haus", "vom", "Nikolaus"]
or
def words():
for w in ["dies", "ist", "das", "Haus", "vom", "Nikolaus"]:
yield w
Regards,
Diez au******@gmail.com a écrit : I use generators a lot. E.g.
def gen_words(text) ... parse text ... yield each word in text
for word in gen_words(text): print word
I don't like the name gen_xxx() very much.
Nor do I.
Looking for some inspiration to name generators. Here are some of my ideas:
enumerate_words gen_words generate_words parse_words walk_words
Any idea? D
Any of these names have different (somewhat implied) semantic to me. I'd
expect enunmerate_words to yield (order, word) pairs, parse_words to
yield tokens, walk_words to traverse a tree of words, etc
As you see, this is much about what it does than what it is. And FWIW,
do you prefix function names s with fun_ ?
you have a naming convention for generators?
No.
> Any idea? Do you have a naming convention for generators?
Sometimes I use the prefix 'iter', like dictionaries have .items() and
..iteritems(). sometimes I use 'x', like range() vs. xrange(). You
could simply use 'i' like some of the functions in the iteritems module
(imap(), izip(), etc). I guess it depends on the project, what you're
doing, your mood at the moment, and the alignment of Jupiter and
Mercury in Aquarius.
iter- clicks for me, thanks :)
wy
infidel wrote: Any idea? Do you have a naming convention for generators?
Sometimes I use the prefix 'iter', like dictionaries have .items() and .iteritems(). sometimes I use 'x', like range() vs. xrange(). You could simply use 'i' like some of the functions in the iteritems module (imap(), izip(), etc). I guess it depends on the project, what you're doing, your mood at the moment, and the alignment of Jupiter and Mercury in Aquarius. au******@gmail.com wrote: I use generators a lot. E.g.
def gen_words(text) ... parse text ... yield each word in text
for word in gen_words(text): print word
I don't like the name gen_xxx() very much. Looking for some inspiration to name generators. Here are some of my ideas:
enumerate_words gen_words generate_words parse_words walk_words
Any idea? Do you have a naming convention for generators?
If it's not a short one where you can see the whole body immediately,
I think it's more important to mention the generator-ness in the
docstring.
Georg This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Derek |
last post by:
The company where I work uses a naming convention that I have
never used before. They use mixed-case letters for public
member functions, but lower-case with underscores for the
rest, like this:...
|
by: cmiddlebrook |
last post by:
Hi there,
I keep finding myself getting inconsistent with naming conventions for
things like member variables, class names etc and I just want to find
something that suits me and stick to it. I...
|
by: Mark Broadbent |
last post by:
stupid question time again to most of you experts but this is something that
continually bothers me.
I am trying to get into the habit of naming variables and controls in an
assembly as per...
|
by: 42 |
last post by:
Hi,
Stupid question:
I keep bumping into the desire to create classes and properties with the
same name and the current favored naming conventions aren't
automatically differentiating them......
|
by: Carl Colijn |
last post by:
Hi all,
Disclaimer: before I might trigger your "let's start a holy war!" button,
I'd like to say I'm not intended to; I just post this message to get some
input and not to promote "Yet Another...
|
by: jjkboswell |
last post by:
I'm trying to pin down a good naming convention for the 3 things
required to implement an event.
You need:
1) a delegate
2) an event
3) an event handler
Below is my understanding of a...
|
by: dm1608 |
last post by:
I'm relatively new to ASP.NET 2.0 and am struggling with trying to find the
best naming convention for the BAL and DAL objects within my database. Does
anyone have any recommendations or best...
|
by: Jonathan Wood |
last post by:
I was just wondering what naming convention most of you use for class
variables.
Underscore, "m_" prefix, camel case, capitalized, etc?
Has one style emerged as the most popular?
Thanks for...
|
by: Smithers |
last post by:
Is it common practise to begin the name of form classes with "frm" (e.g.,
frmOneForm, frmAnotherForm).
Or is that generally considered an outdated convention?
If not "frm" what is a common or...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
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: 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...
|
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,...
|
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: 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,...
|
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,...
|
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...
| |