Re: Handy utilities = Friday Filosofical Finking

2019-03-29 Thread Neil Cerutti
arious applications/systems? > (Python's import rules and restrictions, change control/version > control) I have a lib directory in my PYTHONPATH to dump 'em. -- Neil Cerutti -- https://mail.python.org/mailman/listinfo/python-list

Re: Feature suggestions: "Using declarations" i.e. context managers ("with" blocks) tied to scope/lifetime of the variable rather than to nesting

2019-02-19 Thread Neil Cerutti
gt; logfile.write() > > This becomes more ugly if multiple withs get nested. You don't have to nest them. Check out contextlib.ExitStack. ExitStack is designed to handle situations where you don't always want to enter some context, or you are entering a large number of them. -- Neil Cerutti -- https://mail.python.org/mailman/listinfo/python-list

Re: How to replace space in a string with \n

2019-01-31 Thread Neil Cerutti
xt: > space=\n > > rightText = text-space > > print(rightText) Your code resembles Python code, but it isn't close enough for me to offer reasonable help. You should figure out how to solve your problem *before* you start to write code. A paper and pencil will be required

Re: Python read text file columnwise

2019-01-15 Thread Neil Cerutti
On 2019-01-15, Juris __ wrote: > Hi! > > On 15/01/2019 17:04, Neil Cerutti wrote: >> On 2019-01-11, shibashib...@gmail.com wrote: >>> Hello >>>> >>>> I'm very new in python. I have a file in the format: >>>> >>>> 201

Re: Python read text file columnwise

2019-01-15 Thread Neil Cerutti
8, 7, 5): # approximations item = line[i:i+width] record.append(item) i += width records.append(record) This leaves them all strings, which in my experience is more convenient in practice. You can convert as you go if you want,though it won't look nice and simple any longer. -- Neil Cerutti -- https://mail.python.org/mailman/listinfo/python-list

Re: Are all items in list the same?

2019-01-08 Thread Neil Cerutti
will return True anyway. Neat! I expected that a[0] would be executed in that case, but it is not. -- Neil Cerutti -- https://mail.python.org/mailman/listinfo/python-list

Re: ESR "Waning of Python" post

2018-10-12 Thread Neil Cerutti
On 2018-10-12, Peter J. Holzer wrote: > Neil Cerutti said: >> I imagine that if I stuck with Go long enough I'd develop a >> new coding style that didn't inolve creating useful data >> types. > > I haven't used Go for any real project yet (that may change > next y

Re: Overwhelmed by the Simplicity of Python. Any Recommendation?

2018-10-12 Thread Neil Cerutti
de, but it still works and I can still maintain it with little trouble. -- Neil Cerutti -- https://mail.python.org/mailman/listinfo/python-list

Re: ESR "Waning of Python" post

2018-10-11 Thread Neil Cerutti
On 2018-10-10, Paul Rubin wrote: > Neil Cerutti writes: >> As Stephen said, it's sort of silly not to be aware of those >> issues going in. > > If you're saying ESR messed up by using Python in the first > place for that program, that's not a great advert for Python &

Re: ESR "Waning of Python" post

2018-10-10 Thread Neil Cerutti
around 300 lines, followed by > several pages of reader comments. > > http://esr.ibiblio.org/?p=8161 Thanks for sharing it. -- Neil Cerutti -- https://mail.python.org/mailman/listinfo/python-list

Re: Creating dice game : NEED HELP ON CHECKING ELEMENTS IN A LIST

2018-10-10 Thread Neil Cerutti
roll in result): > # - THIS LINE IS WHERE I NEED HELP # ( if 2, 3, 4, 6 in list: ) > print("you can roll again") > else: > print("you have all 1's and 5's in your result") Ha! Didn't think I'd get to apply DeMorgan's Law so soon. -- Neil Cerutti -- https://mail.python.org/mailman/listinfo/python-list

Re: Any SML coders able to translate this to Python?

2018-09-07 Thread Neil Cerutti
uages to introduce new names for things. You'd consider it wherever you'd consider assigning something to a new name in Python. In this case, it was probably just to avoid writing out that square root calculation twice. Though you could use lambda calculus directly instead, that might be considered

Re: Python shuts down when I try to run a module

2018-07-23 Thread Neil Cerutti
unfortunately it doesn't help when an error occurs, requiring you to put it in a finally block to ensure it happens. -- Neil Cerutti -- https://mail.python.org/mailman/listinfo/python-list

Re: For next loops

2018-07-23 Thread Neil Cerutti
hing like this is possible. "x", "y" and "result" can be unecessary. for ply in range(5): for com in range(5): print(ply, com, end='') if ply == com: print(" Tie") else: print() -- Neil Cerutti -- https://mail.python.org/mailman/listinfo/python-list

Re: doubling the number of tests, but not taking twice as long

2018-07-17 Thread Neil Cerutti
ince you're already using the giant, Swiss Army sledgehammer of the re module, go ahead and use enough features to cover your use case. -- Neil Cerutti -- https://mail.python.org/mailman/listinfo/python-list

Re: Python for beginners or not? [was Re: syntax difference]

2018-06-27 Thread Neil Cerutti
need look-ahead or similar inspection of more than the current item. An alternative is a custom generator or iterator that provides the window you need. -- Neil Cerutti -- https://mail.python.org/mailman/listinfo/python-list

Re: Finding set difference between ranges

2018-04-18 Thread Neil Cerutti
red as a set I don't see how they can be sorted. Are you converting to set and then calling difference? It may still be more efficient than writing your own loop to take advantage of the sorted status of the original objects. -- Neil Cerutti -- https://mail.python.org/mailman/listinfo/python-list

Re: Style Q: Instance variables defined outside of __init__

2018-03-20 Thread Neil Cerutti
tes form "on high", we are simply required to > follow them. > > IOWs, "Do as they _say_, not as logic dictates" The Introduction to Computer Science class I'm taking divided program design into two categories: Top Down Design, and Object Oriented Design. It's good, becau

Re: csv module and NULL data byte

2018-03-01 Thread Neil Cerutti
inary recommendation, but in 10+ years of using > the csv module, I've not found any issues in using text/ascii mode > that were solved by switching to using binary mode. Binary mode was recommended for Python 2, but not 3, where you open in text mode but use newline=''. -- Neil Cerutti -- https://mail.python.org/mailman/listinfo/python-list

Re: Problem with assignment. Python error or mine?

2017-12-21 Thread Neil Cerutti
root variable. Why? > > import numpy as np > > X=np.arange(1, 1, 1) #root variable np.arange creates an object. The assignment makes X refer to that object. > x1=X X refers to the previous object, and then the assignment makes x1 refer to that same object. -- Neil Cerutti --

Re: csv.DictReader line skipping should be considered a bug?

2017-12-11 Thread Neil Cerutti
On 2017-12-11, Neil Cerutti <ne...@norwich.edu> wrote: > On 2017-12-05, Steve D'Aprano <steve+pyt...@pearwood.info> wrote: >> On Wed, 6 Dec 2017 04:20 am, Jason wrote: >>> while iterating over two files, which are line-by-line >>> corresponding. The DictReade

Re: csv.DictReader line skipping should be considered a bug?

2017-12-11 Thread Neil Cerutti
action. When some records are missing--it sets them to None. Except, when all the records are missing, it silently hides the error with no ability provided to recover it. -- Neil Cerutti -- https://mail.python.org/mailman/listinfo/python-list

Re: How to use a regexp here

2017-12-08 Thread Neil Cerutti
gt; fail because the substring is at the start of the line, since 'in' would >> still be true no matter where the desired string is placed. It would be >> useful to see some sample data of the old data, and the new data > > There is now also a line that starts with: > PCH_CPU_TEMP: > > And I do not want that one. You'll probably want to include the ':' in the startswith check, in case someday they also add CPU_TEMP_SOMETHING:. -- Neil Cerutti -- https://mail.python.org/mailman/listinfo/python-list

Re: csv.DictReader line skipping should be considered a bug?

2017-12-05 Thread Neil Cerutti
t full of None, if that's what's in the record? Haw many Nones are too many? -- Neil Cerutti -- https://mail.python.org/mailman/listinfo/python-list

Re: How to use a regexp here

2017-12-04 Thread Neil Cerutti
gt; fail because the substring is at the start of the line, since 'in' would >> still be true no matter where the desired string is placed. It would be >> useful to see some sample data of the old data, and the new data > > There is now also a line that starts with: > PCH_CPU_TEMP: > > And I do not want that one. You'll probably want to include the ':' in the startswith check, in case someday they also add CPU_TEMP_SOMETHING:. -- Neil Cerutti -- https://mail.python.org/mailman/listinfo/python-list

Re: Code Snippets

2017-11-01 Thread Neil Cerutti
import__ > is just so much better! You can import wherever you like--only good style requires you to put them at the top of your file. Moreover, snippets could be a library, with each snippet a function, with the import inside the function. That would keep the module name out of your global namespace. -- Neil Cerutti -- https://mail.python.org/mailman/listinfo/python-list

Re: How to join elements at the beginning and end of the list

2017-10-31 Thread Neil Cerutti
On 2017-10-31, Stefan Ram <r...@zedat.fu-berlin.de> wrote: > Neil Cerutti <ne...@norwich.edu> writes: >>You can use the % operator instead of +, and a generator >>expression instead of map. It's a pretty small improvement, >>though. > > "Improvement

Re: How to join elements at the beginning and end of the list

2017-10-31 Thread Neil Cerutti
value_list)) At least... I THINK you can use that generator expression in 2.7. -- Neil Cerutti -- https://mail.python.org/mailman/listinfo/python-list

Re: Compression of random binary data

2017-10-23 Thread Neil Cerutti
t; take up 7 bytes in ZSCII as well. >> >> http://inform-fiction.org/zmachine/standards/z1point0/sect03.html > > not sure how 16 characters can be represented by either ascii > or zscii in only 8 bytes Oops! I hastily counted completely wrong. It's 10 bytes in ZSCII versio

Re: Compression of random binary data

2017-10-23 Thread Neil Cerutti
nt compress random >> data. his compression is simply removing redundant space from >> an inefficient coding > > I suspect he is using ASCII and storing one value in each byte. There's also ZSCII, which stores roughly 3 characters every 2 bytes. Since all the digits are in A2, this sequence would take up 7 bytes in ZSCII as well. http://inform-fiction.org/zmachine/standards/z1point0/sect03.html -- Neil Cerutti -- https://mail.python.org/mailman/listinfo/python-list

Re: Lies in education [was Re: The "loop and a half"]

2017-10-13 Thread Neil Cerutti
On 2017-10-13, Steve D'Aprano <steve+pyt...@pearwood.info> wrote: > On Fri, 13 Oct 2017 11:54 pm, Gregory Ewing wrote: > >> Neil Cerutti wrote: >>> I can tell at a glance if a parameter is expected to be >>> modifiable just by looking at the function signature

Re: Lies in education [was Re: The "loop and a half"]

2017-10-12 Thread Neil Cerutti
gt;> If not, you couldn't pass a string literal to a function >> having prototype void f(char *s); > > That *ought* to be prevented. That's the whole point. I'm far less experienced in C, but I threw up my hands and stopped bothering with const qualifiers in C due to such headac

Re: Lies in education [was Re: The "loop and a half"]

2017-10-12 Thread Neil Cerutti
On 2017-10-11, Gregory Ewing <greg.ew...@canterbury.ac.nz> wrote: > Neil Cerutti wrote: >> I dig const qualifiers, even though I'm comletely fine with >> their absence from Python. > > Out of curiosity, do you have any insights into why you like > them in C++, if you

Re: Lies in education [was Re: The "loop and a half"]

2017-10-11 Thread Neil Cerutti
ce from Python. I'd use C++ for stuff--but Python is perfect for my needs, meanwhile the advantages I'd get from using C++ wouldn't be relevant to my work. If I ever need to write a device driver I'm really screwed. -- Neil Cerutti -- https://mail.python.org/mailman/listinfo/python-list

Re: Pedagogical style [was Re: The "loop and a half"]

2017-10-06 Thread Neil Cerutti
an's way of thinking about and asking questions about Python has been of great interest to me, and provided entertainment and enlightenment. -- Neil Cerutti -- https://mail.python.org/mailman/listinfo/python-list

Re: Easier way to do this?

2017-10-05 Thread Neil Cerutti
0-second job using a pivot table in Excel. Office manager, learn thy Excel! On the other hand, I think Python's csv module is a killer app, so I do recommend taking the opportunity to learn csv.DictReader and csv.DictWriter for your own enjoyment. -- Neil Cerutti -- https://mail.python.or

Re: The "loop and a half"

2017-10-04 Thread Neil Cerutti
ay to teach iterators. If you insist they understand the iterator protocol and exception handling first they're bound to think iteration is a hovercraft full of eels. -- Neil Cerutti -- https://mail.python.org/mailman/listinfo/python-list

Re: Beginners and experts (Batchelder blog post)

2017-09-28 Thread Neil Cerutti
of them are good at explaining what they know in a comprehensible and entertaining way. I believe you will benefit from and even enjoy some of the literature. Here's a recent favorite: "The Pragmatic Programmer", Andrew Hunt and David Thomas. ISBN-13: 978-0201616224 -- Neil Cerutti -- https://mail.python.org/mailman/listinfo/python-list

OT: Drain specialist Was: Beginners and experts

2017-09-28 Thread Neil Cerutti
whiz-bang C programmer to configure your email server--it isn't that he or she *can't* do it... -- Neil Cerutti -- https://mail.python.org/mailman/listinfo/python-list

Re: Python scripting as side job

2017-09-26 Thread Neil Cerutti
ile spec, at least on one side of the pipeline. Some experience in the industry you want to script for will really be required, even in such simple cases. -- Neil Cerutti -- https://mail.python.org/mailman/listinfo/python-list

Re: Code for addition

2017-08-07 Thread Neil Cerutti
- 101 + 1) * (101 + 2033) / 2 You could also calculate it with a combination of sum and range builtins, as others have hinted, and if it's homework that's probably a good idea. -- Neil Cerutti -- https://mail.python.org/mailman/listinfo/python-list

Re: Grapheme clusters, a.k.a.real characters

2017-07-14 Thread Neil Cerutti
ences of bytes. It provides separate API's that allow you to regard those bytes as either plain old bytes, or as a sequence of runes (not-necessarily normalized codepoints). If your bytes strings aren't in UTF-8, then Go Away. https://blog.golang.org/strings -- Neil Cerutti -- https://mail.python.org/mailman/listinfo/python-list

Re: Best way to ensure user calls methods in correct order?

2017-06-23 Thread Neil Cerutti
with a generator in Python is going to feel awkward. -- Neil Cerutti -- https://mail.python.org/mailman/listinfo/python-list

Re: Namedtuple problem #32.11.d

2017-06-07 Thread Neil Cerutti
arn concepts and illuminate dark corners of both my own skill and Python's features. An Excel spreadsheet that represents a table of data is fairly simple to map onto a Python dict. One nearly codeless way is to export it from Excel as a csv file and then read it with csv.DictReader. -- Neil Ce

Re: Namedtuple problem #32.11.d

2017-06-06 Thread Neil Cerutti
at this point, after only one bad experience trying to work around my choice of container. -- Neil Cerutti -- https://mail.python.org/mailman/listinfo/python-list

Re: Python DB API - commit() v. execute("commit transaction")?

2017-06-02 Thread Neil Cerutti
0, SQLite3 > 3.13.0) has no autocommit attribute at all. I checked at the > module, connection and cursor levels. You get autocommit with sqlite3 by setting isolation_level=None on the connection object. https://docs.python.org/2/library/sqlite3.html#sqlite3-controlling-transactions -- Neil Cerutt

Re: Python DB API - commit() v. execute("commit transaction")?

2017-06-02 Thread Neil Cerutti
On 2017-06-02, Dennis Lee Bieber <wlfr...@ix.netcom.com> wrote: > > A bit of a long free-association rambling... > > On Fri, 2 Jun 2017 12:07:45 + (UTC), Neil Cerutti > <ne...@norwich.edu> declaimed the following: >>You're probably not expected

Re: Python DB API - commit() v. execute("commit transaction")?

2017-06-02 Thread Neil Cerutti
nsaction control commands from different levels of abstraction, e.g., only call 'commit' directly if you called 'begin' directly. -- Neil Cerutti -- https://mail.python.org/mailman/listinfo/python-list

Re: [OT] How to improve my programming skills?

2017-06-01 Thread Neil Cerutti
langauge that concentrates on functional programming with immutable state if you haven't done it before. The book that worked for me was Simply Scheme https://people.eecs.berkeley.edu/~bh/ss-toc2.html, but that's sorta ancient history now and I'm sure there's lots more options out there.

Re: "pandas" pronunciation

2017-04-05 Thread Neil Cerutti
On 2017-04-03, Jay Braun <lyngw...@gmail.com> wrote: > I hear people say it like the plural of "panda", and others as > "panduss". Is there a correct way? I think it is pronounced like the regular word. The second a is schwa in both the singular and plur

Re: Manual parameter substitution in sqlite3

2017-02-28 Thread Neil Cerutti
the column-names portion of an INSERT statement. quoted_val, = c.execute("SELECT quote(?);", (val,)).fetchone() -- Neil Cerutti -- https://mail.python.org/mailman/listinfo/python-list

Re: How to store properties

2017-02-08 Thread Neil Cerutti
arser, but have the feeling that it is not really >> used. > > I use it a lot ;-) Me too. I wrote a script once to convert all my .cfg files to JSON at one point while trying out a switch from Python to Go, but never made the changeover. -- Neil Cerutti -- https://mail.python.org/mailman/listinfo/python-list

Re: Using query parameters subtitution outside of execute()

2014-03-28 Thread Neil Cerutti
manageable that the ones I used in Python ... C could provide more friendly general purpose containers in its library, but doesn't. There are some good free ones: glib, for example. Cython provides a really nice in-between level. -- Neil Cerutti -- https://mail.python.org/mailman/listinfo/python

Re: Closure/method definition question for Python 2.7

2014-03-11 Thread Neil Cerutti
. -- Neil Cerutti -- https://mail.python.org/mailman/listinfo/python-list

Re: golang OO removal, benefits. over python?

2014-03-11 Thread Neil Cerutti
is a draw. Go's tools are pretty awesome, and are scheduled for improvements. If you can get by with its built in types (or simple aggregates of them) it feels quite expressive. -- Neil Cerutti -- https://mail.python.org/mailman/listinfo/python-list

Re: How security holes happen

2014-03-05 Thread Neil Cerutti
underestimated how much we like to use our programming languages as non-RPN calculators. -- Neil Cerutti -- https://mail.python.org/mailman/listinfo/python-list

Re: Can global variable be passed into Python function?

2014-02-28 Thread Neil Cerutti
statement for an example of what it might look like in Python. Except you'd get it without labeled break or the fallthrough statement. Would you still want to use it? -- Neil Cerutti -- https://mail.python.org/mailman/listinfo/python-list

Re: References, and avoiding use of ???variable??? (was: Can global variable be passed into Python function?)

2014-02-28 Thread Neil Cerutti
of the called function. Am I oversimplifying? -- Neil Cerutti -- https://mail.python.org/mailman/listinfo/python-list

Re: Can one use Python to learn and even apply Functional Programming?

2014-02-18 Thread Neil Cerutti
to that mind-bending experience. http://www.eecs.berkeley.edu/~bh/ss-toc2.html I wouldn't recommend trying to learn anything at the same time as learning Haskell. ;) -- Neil Cerutti -- https://mail.python.org/mailman/listinfo/python-list

Re: Python programming

2014-02-13 Thread Neil Cerutti
the beginning, but it's a pretty good place. -- Neil Cerutti -- https://mail.python.org/mailman/listinfo/python-list

Re: A curious bit of code...

2014-02-13 Thread Neil Cerutti
. But good point! That's a pretty sneaky way to avoid checking for a zero-length string. Is it a popular idiom? -- Neil Cerutti -- https://mail.python.org/mailman/listinfo/python-list

Re: A curious bit of code...

2014-02-13 Thread Neil Cerutti
] == '': ... It is wrong to avoid the obvious. Needlessly ornate or clever code will only irritate the person who has to read it later; most likely yourself. -- Neil Cerutti -- https://mail.python.org/mailman/listinfo/python-list

Re: A curious bit of code...

2014-02-13 Thread Neil Cerutti
easy to forget exactly why startswith and endswith even exist. -- Neil Cerutti -- https://mail.python.org/mailman/listinfo/python-list

Re: A curious bit of code...

2014-02-13 Thread Neil Cerutti
, in inner key[0] == '' and key[-1] == '' IndexError: string index out of range The corrected version key and key[0] == '' and key[-1] == '' probably still wins the Pretty Unimportant Olympics. -- Neil Cerutti -- https://mail.python.org/mailman/listinfo/python-list

Re: pip3.x error using LIST instead of list

2014-02-12 Thread Neil Cerutti
, Windows, and Linux computers for years: disable the caps-lock key I really liked rebinding it to Left-CTRL. I only stopped doing that because it screwed up my work flow when not at a keyboard I could remap. -- Neil Cerutti -- https://mail.python.org/mailman/listinfo/python-list

Re: Finding size of Variable

2014-02-11 Thread Neil Cerutti
, insulted, or have his few controversial opinions brought into other topics. Tim's post was responding to a specific, well-presented criticism of Python's string implementation. Left unchallenged, it might linger unhappily in the air, like a symphony ended on a dominant 7th chord. -- Neil Cerutti

Re: parse a csv file into a text file

2014-02-06 Thread Neil Cerutti
('raw.csv', 'b') -- Neil Cerutti -- https://mail.python.org/mailman/listinfo/python-list

Re: parse a csv file into a text file

2014-02-06 Thread Neil Cerutti
On 2014-02-06, Tim Chase python.l...@tim.thechases.com wrote: On 2014-02-06 17:40, Mark Lawrence wrote: On 06/02/2014 14:02, Neil Cerutti wrote: You must open the file in binary mode, as that is what the csv module expects in Python 2.7. newline handling can be enscrewed if you forget

Re: Help with some python homework...

2014-01-31 Thread Neil Cerutti
program's answer with. 2. A general idea of how to solve the problem. It's often a mistake to start writing code. Eventually you'll be able to go directly from problem to code more often, but it will take practice. -- Neil Cerutti -- https://mail.python.org/mailman/listinfo/python-list

Re: Another surprise from the datetime module

2014-01-30 Thread Neil Cerutti
to print a timedelta without the fractions of seconds. The most straight-forward is: print td.replace(microseconds=0) That would be nice. In the meantime, this works for your use case: td -= td % timedelta(seconds=1) -- Neil Cerutti -- https://mail.python.org/mailman/listinfo/python-list

Re: buggy python interpretter or am I missing something here?

2014-01-27 Thread Neil Cerutti
are. Isn't that right, Mr... Poopy-Pants? -- Neil Cerutti -- https://mail.python.org/mailman/listinfo/python-list

Re: Elementree and insert new element if it is not present - FIXED

2014-01-24 Thread Neil Cerutti
. But maybe I'm just naive. -- Neil Cerutti -- https://mail.python.org/mailman/listinfo/python-list

Re: Can post a code but afraid of plagiarism

2014-01-22 Thread Neil Cerutti
, is most likely to be detected. Well, that and submitting one of the entrapment-purposed answers that are sometimes made availalbe here and elsewhere. -- Neil Cerutti -- https://mail.python.org/mailman/listinfo/python-list

Re: Early retirement project?

2014-01-22 Thread Neil Cerutti
On 2014-01-22, wxjmfa...@gmail.com wxjmfa...@gmail.com wrote: In fact, Python just becomes the last tool I (would) recommend, especially for non-ascii users. Have a care, jmf. People unfamiliar with your opinions might take that seriously. -- Neil Cerutti -- https://mail.python.org/mailman

Re: regex multiple patterns in order

2014-01-20 Thread Neil Cerutti
, for example, when editing text with gvim. But when I want to use them in Python I have to contend with the re module. I've never become comfortable with it. -- Neil Cerutti -- https://mail.python.org/mailman/listinfo/python-list

Re: regex multiple patterns in order

2014-01-20 Thread Neil Cerutti
On 2014-01-20, Devin Jeanpierre jeanpierr...@gmail.com wrote: On Mon, Jan 20, 2014 at 8:16 AM, Mark Lawrence breamore...@yahoo.co.uk wrote: On 20/01/2014 16:04, Neil Cerutti wrote: I use regular expressions regularly, for example, when editing text with gvim. But when I want to use them

Re: Python glob and raw string

2014-01-16 Thread Neil Cerutti
with an actual file path. # This is where I add to the data. In your case you might not want to process unless the path also looks like an xml file. mine = Miner('myxmldir') Hmmm... I might be doing too much in __init__. ;) -- Neil Cerutti -- https://mail.python.org/mailman/listinfo/python-list

Re: Python glob and raw string

2014-01-16 Thread Neil Cerutti
a convenient place to hang the functions. -- Neil Cerutti -- https://mail.python.org/mailman/listinfo/python-list

Re: Experiences/guidance on teaching Python as a first programming language

2013-12-19 Thread Neil Cerutti
is no problem; in fact, it feels darn good. And another thing: How many other languages have their very own calling convention? -- Neil Cerutti -- https://mail.python.org/mailman/listinfo/python-list

Re: Experiences/guidance on teaching Python as a first programming language

2013-12-18 Thread Neil Cerutti
member lookup for both structs and pointers to structs. The - syntax perhaps was needful in the days before function prototypes. -- Neil Cerutti -- https://mail.python.org/mailman/listinfo/python-list

Re: Experiences/guidance on teaching Python as a first programming language

2013-12-17 Thread Neil Cerutti
the equivalent written in C. I can't think of a reference, but I to recall that bugs-per-line-of-code is nearly constant; it is not language dependent. So, unscientifically, the more work you can get done in a line of code, then the fewer bugs you'll have per amount of work done. -- Neil Cerutti

Re: Tree library - multiple children

2013-12-12 Thread Neil Cerutti
Python makes it very easy to manipulate such a structure. It isn't clear that you need more than that yet. -- Neil Cerutti -- https://mail.python.org/mailman/listinfo/python-list

Re: Experiences/guidance on teaching Python as a first programming language

2013-12-11 Thread Neil Cerutti
in the long run. NAILS Nails were verboten in my high school wood working class... We used dowels and glue; chisels to carve dove-tails; etc. ... You lucky BASTARD! We had to build bookcases out of banana leaves held together with our own spittle. -- Neil Cerutti

Re: One liners

2013-12-09 Thread Neil Cerutti
, then possibly rewrite it once her first few programs become horrifying years later. I haven't found time to rewrite all of mine yet. I still have a program I use almost every day with an __init__ that returns invalid objects but helpfully sets self.valid to 0. -- Neil Cerutti -- https

Re: Why is there no natural syntax for accessing attributes with names not being valid identifiers?

2013-12-06 Thread Neil Cerutti
On 2013-12-04, Piotr Dobrogost p...@google-groups-2013.dobrogost.net wrote: On Wednesday, December 4, 2013 10:41:49 PM UTC+1, Neil Cerutti wrote: not something to do commonly. Your proposed syntax leaves the distinction between valid and invalid identifiers a problem the programmer has

Re: Does Python optimize low-power functions?

2013-12-06 Thread Neil Cerutti
can see is it quickly returns zero when modulus is one. I'm not a skilled or experienced CPython source reader, though. -- Neil Cerutti -- https://mail.python.org/mailman/listinfo/python-list

Re: [OT] Managing Google Groups headaches

2013-12-04 Thread Neil Cerutti
easier than emmigrating from a police state. Moreover, I'll always feel that I deserve more than I actually do deserve. -- Neil Cerutti -- https://mail.python.org/mailman/listinfo/python-list

Re: Python Unicode handling wins again -- mostly

2013-12-04 Thread Neil Cerutti
. -- Neil Cerutti -- https://mail.python.org/mailman/listinfo/python-list

Re: Why is there no natural syntax for accessing attributes with names not being valid identifiers?

2013-12-04 Thread Neil Cerutti
the distinction between valid and invalid identifiers a problem the programmer has to deal with. It doesn't unify access to attributes the way the getattr and setattr do. -- Neil Cerutti -- https://mail.python.org/mailman/listinfo/python-list

Re: Python Unicode handling wins again -- mostly

2013-12-03 Thread Neil Cerutti
. There are good examples here: http://unicode.org/reports/tr15/ Thanks for this excellent post. Agreed. -- Neil Cerutti -- https://mail.python.org/mailman/listinfo/python-list

Re: The input and output is as wanted, but why error?

2013-12-03 Thread Neil Cerutti
: print(x) else: SystemExit The input and output is as wanted, but my answer keep rejected, here is my source code http://txt.do/1smv No, your program outputs nothing. That's bound to fail. ;) How is your program supposed to work, in your own words? -- Neil Cerutti -- https

Re: The input and output is as wanted, but why error?

2013-12-03 Thread Neil Cerutti
On 2013-12-03, geezl...@gmail.com geezl...@gmail.com wrote: x = input() Your first problem is that input() returns text only up the a newline, and then stops. So you are reading the initial number line, but never reading the rest of the lines. -- Neil Cerutti -- https://mail.python.org

Re: Managing Google Groups headaches

2013-12-02 Thread Neil Cerutti
portal is poor marketing. I wish they'd never bought dejanews. -- Neil Cerutti -- https://mail.python.org/mailman/listinfo/python-list

Re: Managing Google Groups headaches

2013-12-02 Thread Neil Cerutti
On 2013-12-02, Roy Smith r...@panix.com wrote: In article mailman.3461.1385989809.18130.python-l...@python.org, Neil Cerutti ne...@norwich.edu wrote: On 2013-11-28, Roy Smith r...@panix.com wrote: In article RCJlu.5$rx5.0@fx05.am4, Alister alister.w...@ntlworld.com wrote: Perhaps

Re: Wrapping around a list

2013-11-27 Thread Neil Cerutti
', 'N') ('L', 'E', 'Q', 'N') For some reason I've got more 2-character combinations than you, though. -- Neil Cerutti -- https://mail.python.org/mailman/listinfo/python-list

Re: Python and PEP8 - Recommendations on breaking up long lines?

2013-11-27 Thread Neil Cerutti
() as stack: input = stack.enter_context(open(self.full_path, 'r')) writer = csv.writer(stack.enter_context(open(self.output_csv))) When working with a csv file I like how it removes the output temporary file object variable, though if you needed it for some reason you could keep it. -- Neil

Re: parsing nested unbounded XML fields with ElementTree

2013-11-26 Thread Neil Cerutti
(major=3, minor=3, micro=2, releaselevel='final', serial=0) Node A Nest Node B Nest A Node C Nest A/B Node D Nest A/B/C Node E Nest A/B/C/D -- Neil Cerutti -- https://mail.python.org/mailman/listinfo/python-list

Re: Newbie - Trying to Help a Friend

2013-11-21 Thread Neil Cerutti
literature, The Wombles, and a British TV show, Steptoe and Son, but the characters work fine on their own. But even so, I agree that a footnote is a good idea. And I haven't always lived up to that ideal, myself. -- Neil Cerutti mr.cerutti+pyt...@gmail.com -- https://mail.python.org/mailman/listinfo

Fwd: parsing RSS XML feed for item value

2013-11-20 Thread Neil Cerutti
Larry Wilson itd...@gmail.com via python.org 10:39 PM (10 hours ago) wrote: Wanting to parse out the the temperature value in the w:current element, just after the guid element using ElementTree or xml.sax. Since you aren't building up a complex data structure, xml.sax will be an OK choice.

Re: Using try-catch to handle multiple possible file types?

2013-11-20 Thread Neil Cerutti
. with contextlib.ExitStack() as stack: try: f = gzip.open('blah.txt', 'rb') except IOError: f = open('blah.txt', 'rb') stack.enter_context(f) for line in f: print(line) -- Neil Cerutti On Tue, Nov 19, 2013 at 8:56 PM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info

  1   2   3   4   5   6   7   8   9   10   >