Re: csv module and NULL data byte

2018-03-01 Thread Neil Cerutti
mendation, 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: Style Q: Instance variables defined outside of __init__

2018-03-20 Thread Neil Cerutti
t;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, be

Re: Finding set difference between ranges

2018-04-18 Thread Neil Cerutti
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: Python for beginners or not? [was Re: syntax difference]

2018-06-27 Thread Neil Cerutti
d 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: doubling the number of tests, but not taking twice as long

2018-07-17 Thread Neil Cerutti
isplay and PatternFov? In other words, since 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: For next loops

2018-07-23 Thread Neil Cerutti
g 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: Python shuts down when I try to run a module

2018-07-23 Thread Neil Cerutti
h 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: Any SML coders able to translate this to Python?

2018-09-07 Thread Neil Cerutti
functional languages 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,

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: ESR "Waning of Python" post

2018-10-10 Thread Neil Cerutti
;t agree with, but I think > it is worth reading. It is 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: 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 f

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

2018-10-12 Thread Neil Cerutti
on code, 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-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

Re: Are all items in list the same?

2019-01-08 Thread Neil Cerutti
#x27;all' 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: Python read text file columnwise

2019-01-15 Thread Neil Cerutti
i = 0 for width in (30, 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: 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: >>>> >>>>

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

2019-01-31 Thread Neil Cerutti
' ') in text: > 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 an

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
hat > 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: Handy utilities = Friday Filosofical Finking

2019-03-29 Thread Neil Cerutti
on paper, ... If the former, how do you > access/import them from the various 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: Creating a function for a directory

2013-11-12 Thread Neil Cerutti
create the data file manually, race conditions seem unlikely. -- Neil Cerutti -- https://mail.python.org/mailman/listinfo/python-list

Re: pypy and ctypes

2013-11-14 Thread Neil Cerutti
de runs and how clever you are at using cython. PyPy isn't designed to speed up programs that run for a few hundred milliseconds and then complete, though it might sometimes work for that. -- Neil Cerutti -- https://mail.python.org/mailman/listinfo/python-list

Re: Automation

2013-11-15 Thread Neil Cerutti
or oats. Also "far too arrogant". I just learned about this kind of error yesterday while browsing the programming reddit! http://en.wikipedia.org/wiki/Muphry's_law -- Neil Cerutti -- https://mail.python.org/mailman/listinfo/python-list

Re: python 3.3 repr

2013-11-15 Thread Neil Cerutti
hing is utf-8, right? RIGHT?!?" It also has the interesting behavior that indexing strings retrieves bytes, while iterating over them results in a sequence of runes. It comes with support for no encodings save utf-8 (natively) and utf-16 (if you work at it). Is that really enough? -- Neil Cerutti

Re: Automation

2013-11-18 Thread Neil Cerutti
udgeon and maybe overly sensitive, > but I felt a need to vent a bit. The cases where written and spoken English diverge are hotbets of word usage problems. I'm glad the issue doesn't exist for programming languages, which thankfully don't really have a colloquial or spoken v

Re: KeyboardInterrupt close failed in file object destructor: sys.excepthook is missing lost sys.stderr

2013-11-19 Thread Neil Cerutti
thm. Can you show sample input and output? Can you describe the algorithm in plain English? -- Neil Cerutti -- https://mail.python.org/mailman/listinfo/python-list

Re: Newbie - Trying to Help a Friend

2013-11-19 Thread Neil Cerutti
. (13006517)" > > Any help would be appreciated What has A Friend written so far? Where are you stuck? -- Neil Cerutti On Tue, Nov 19, 2013 at 1:40 PM, wrote: > Hi, > > A Friend is doing maths in University and has had some coursework to do with > python. > > The que

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 > " ElementTree or xml.sax. Since you aren't building up a complex data structure, xml.sax will be an OK choice. Here's a quick and dirty job: import io import xm

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

2013-11-20 Thread Neil Cerutti
ases where entering context is optional, and so also works for this use case. 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

Re: Newbie - Trying to Help a Friend

2013-11-21 Thread Neil Cerutti
ies of British children's 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 -- https://mail.python.org/mailman/listinfo/python-list

Re: parsing nested unbounded XML fields with ElementTree

2013-11-26 Thread Neil Cerutti
ef process(self, name): print("Node {} Nest {}".format(name, '/'.join(self.names))) # Do your stuff. def endElement(self, name): self.names.pop() print(sys.version_info) handler = NodeHandler() parser = sax.parse(io.StringIO(the_xml), handler) Output: sys.version_info

Re: Wrapping around a list

2013-11-27 Thread Neil Cerutti
nations(s, i+1): print(comb) Output: ('L',) ('E',) ('Q',) ('N',) ('L', 'E') ('L', 'Q') ('L', 'N') ('E', 'Q') ('E', 'N') ('Q', 'N') ('L', 'E', 'Q') ('L', 'E', 'N') ('L', 'Q', 'N') ('E', 'Q', '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
e them. with contextlib.ExitStack() 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

Re: Managing Google Groups headaches

2013-12-02 Thread Neil Cerutti
lar, into a low opinion of Google. The crappy usenet 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 wrote: > In article , > Neil Cerutti wrote: > >> On 2013-11-28, Roy Smith wrote: >> > In article , >> > Alister wrote: >> >> Perhaps the best option is for everybody to bombard Google >> >> with bug repor

Re: Python Unicode handling wins again -- mostly

2013-12-03 Thread Neil Cerutti
point sequence into one, and normalizing can lose or mangle information. 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
> 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://mail.python.org/mailman/listinfo/python-list

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

2013-12-03 Thread Neil Cerutti
On 2013-12-03, 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/mailman/li

Re: [OT] Managing Google Groups headaches

2013-12-04 Thread Neil Cerutti
cost of switching isn't zero, but it's much 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
On 2013-12-04, wxjmfa...@gmail.com wrote: > Yon intuitively pointed a very important feature of "unicode". > However, it is not necessary, this is exactly what unicode does > (when used properly). Unicode only provides character sets. It's not a natural language par

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

2013-12-04 Thread Neil Cerutti
ntifiers as attributes is generally a bad idea, not something to do commonly. Your proposed syntax leaves 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: 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 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 to dea

Re: Does Python optimize low-power functions?

2013-12-06 Thread Neil Cerutti
ization of the style I think your describing that I 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: One liners

2013-12-09 Thread Neil Cerutti
h a fish. A new Python programmer can generally just get her code working in a fairly comfortable way, 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

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

2013-12-11 Thread Neil Cerutti
make them use rocks to bang nails >>in, because it will make them better carpenters 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. ...

Re: Tree library - multiple children

2013-12-12 Thread Neil Cerutti
on 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-17 Thread Neil Cerutti
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: Experiences/guidance on teaching Python as a first programming language

2013-12-18 Thread Neil Cerutti
wo ints being what Py3 does). Why > adorn pointer usage? Indeed. Golang allows . to do 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-19 Thread Neil Cerutti
rain-damage, writing C code 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: Python glob and raw string

2014-01-16 Thread Neil Cerutti
n(path, '*')): if os.path.isdir(fname): self.descend(fname) else: self.process(fname) def process(self, path): # Do what I want done with an actual file path. # This is where I add to the data. In your case you m

Re: Python glob and raw string

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

Re: regex multiple patterns in order

2014-01-20 Thread Neil Cerutti
ssions regularly, 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 wrote: > On Mon, Jan 20, 2014 at 8:16 AM, Mark Lawrence > 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 in Python

Re: Can post a code but afraid of plagiarism

2014-01-22 Thread Neil Cerutti
m, how > can judge the OP's reaction to it? Obvious copying of another person's program, nearly verbatim, 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 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/listinfo/

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

2014-01-24 Thread Neil Cerutti
maybe I'm just naive. -- 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
ely, just like the responsible adults that we are. Isn't that right, Mr... Poopy-Pants? -- Neil Cerutti -- https://mail.python.org/mailman/listinfo/python-list

Re: Another surprise from the datetime module

2014-01-30 Thread Neil Cerutti
case was wanting 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: Help with some python homework...

2014-01-31 Thread Neil Cerutti
answer to test your 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: parse a csv file into a text file

2014-02-06 Thread Neil Cerutti
in Python 2.7. newline handling can be enscrewed if you forget. file = open('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 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 enscrewe

Re: Finding size of Variable

2014-02-11 Thread Neil Cerutti
is 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 -- https://mail.python.org/mailman/listinfo/python-list

Re: pip3.x error using LIST instead of list

2014-02-12 Thread Neil Cerutti
DOS, 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: Python programming

2014-02-13 Thread Neil Cerutti
ust 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
. There will be an exception only if it is zero-length. 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
the fastest after all? I think the following would occur to someone first: if key[0] == '<' and key[-1] == '>': ... 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
ll catch that with your unit tests ;) It's 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
<' and key[-1] == '>'" > Traceback (most recent call last): > File "P:\Python34\lib\timeit.py", line 292, in main > x = t.timeit(number) > File "P:\Python34\lib\timeit.py", line 178, in timeit > timing = self.inner(it, self.timer) > File "", line 6, 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: Can one use Python to learn and even apply Functional Programming?

2014-02-18 Thread Neil Cerutti
a followup 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: Can global variable be passed into Python function?

2014-02-28 Thread Neil Cerutti
enough features to bother with its implemention. Check out Go's switch 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
riables in the local symbol table of the called function. Am I oversimplifying? -- Neil Cerutti -- https://mail.python.org/mailman/listinfo/python-list

Re: How security holes happen

2014-03-05 Thread Neil Cerutti
let you, gulp, add more. Well, that or lisp's designers severely 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: Closure/method definition question for Python 2.7

2014-03-11 Thread Neil Cerutti
gt; NameError: global name 'x' is not defined. > > In the snippet, x is neither local to __init__() nor global to > the module. It is in the class scope. You can refer to it in > one of two ways: > >Test.x > > or: > >self.x The latter will work only to

Re: golang OO removal, benefits. over python?

2014-03-11 Thread Neil Cerutti
mbined with duck typing and simple distribution of applications 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: Using query parameters subtitution outside of execute()

2014-03-28 Thread Neil Cerutti
ry less 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-list

Re: PEP8 79 char max

2013-07-31 Thread Neil Cerutti
xprience, too. Besides, after studying The Pragmatic Programmer I removed nearly all the tables from my code and reference them (usually with csv module) instead. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: PEP8 79 char max

2013-07-31 Thread Neil Cerutti
On 2013-07-31, Grant Edwards wrote: > On 2013-07-31, Neil Cerutti wrote: >> Besides, after studying The Pragmatic Programmer I removed >> nearly all the tables from my code and reference them (usually >> with csv module) instead. > > I don't understand. That jus

Re: Editing tabular data [was: PEP8 79 char max]

2013-07-31 Thread Neil Cerutti
(for example when I want to add instructions to your assembler). >> >> My guess is it would be more foolproof to edit that stuff with a >> spreadsheet. > > There's nothing foolproof about using a spreadsheet! I edit csv files using Excel all the time. But I don'

Re: PEP8 79 char max

2013-07-31 Thread Neil Cerutti
On 2013-07-31, Grant Edwards wrote: > On 2013-07-31, Neil Cerutti wrote: >> On 2013-07-31, Grant Edwards wrote: >>> On 2013-07-31, Neil Cerutti wrote: >>>> Besides, after studying The Pragmatic Programmer I removed >>>> nearly all the tables from my

Re: Editing tabular data [was: PEP8 79 char max]

2013-08-01 Thread Neil Cerutti
mined by a person we have to literally query to discover. I think I can see the potential problems. Two special codes for amount is managable, but the more special cases I end up creating the more of a mess I get. Plus, I haven't really documented the file. Most of the information is

Re: Best practice for connections and cursors

2013-08-01 Thread Neil Cerutti
maybe I'll want to someday. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: Does Python 'enable' poke and hope programming?

2013-08-01 Thread Neil Cerutti
wasted my time, of course. As I said, I disagree that the speed of using an interpreter is the main issue. Changing certain things, even big things, in a Python program is often much easier than changing something in , say, a C program, due to Duck-Typing and dynamic typing. So experimentation is easier thanks to more maleable code. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: Simulate `bash` behaviour using Python and named pipes.

2013-08-05 Thread Neil Cerutti
ng from a temp file. You'll have to create the temp file and manage attaching processes to it yourself. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: Enum vs OrderedEnum

2013-08-07 Thread Neil Cerutti
e the game goes well :-) > > It's actually a reimplementation of a game from 1993, so I'm > somewhat stuck with the terminology. I haven't played MOO1 for at least a month. :) -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: right adjusted strings containing umlauts

2013-08-08 Thread Neil Cerutti
string with no Umlaut it uses 3 characters, but for an > Umlaut it uses only 2 characters. > > I guess it has to to with unicode. > How do I get it right? You guessed it! Use unicode strings instead of byte strings, e.g., u"...". -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: c# async, await

2013-08-22 Thread Neil Cerutti
thon.org/dev/peps/pep-3156/ There's also Twisted: http://twistedmatrix.com/trac/ -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: How to send broadcast IP address to network?

2013-08-23 Thread Neil Cerutti
ameError: name 's' is not defined I bet that's not the same traceback you get. Furthermore, port isn't defined either. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: PEPs should be included with the documentation download

2013-08-23 Thread Neil Cerutti
turn out to be > quite high, but it's not an unreasonable question. I use the compiled html/windows help and the integrated with the interpreter html version of the Python docs, both downloaded and installed for easy access. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: Python variable as a string

2013-08-23 Thread Neil Cerutti
tring', anothervar='anotherstring') > anotherdict = dict() > if : > anotherdict[akey] = adict['var'] anotherdict[akey] = adict[str(var)] Will actually work, though you might prefer: anotherdict[akey] = adict[''.join(var)] Try them out and see. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: Checking homogeneity of Array using List in Python

2013-08-26 Thread Neil Cerutti
st it into int and Accept. > Else, I would like to skip that input. > > eg. my input is ['1', ' ', 'asdasd231231', '1213asasd', '43242'] > I want it to be interpreted as: > [1, [None], [None], [None], 43242] > > NOTE: NO INB

Re: Checking homogeneity of Array using List in Python

2013-08-27 Thread Neil Cerutti
On 2013-08-26, Joshua Landau wrote: > On 26 August 2013 14:49, Neil Cerutti wrote: >> On 2013-08-25, sahil301...@gmail.com wrote: >>> >>> eg. my input is ['1', ' ', 'asdasd231231', '1213asasd', '43242'] >>> I

Re: New VPS Provider needed

2013-08-27 Thread Neil Cerutti
can't understand how this savant at anti-killfile-fu can't otherwise manage his server. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: New VPS Provider needed

2013-08-27 Thread Neil Cerutti
PLEASE stop baiting Nikos with snide remarks. It makes > this a very unpleasant environment, and sets the tone of the > community, badly. I limit myself to one snide remark every time he escapes my killfile. 'Cause I wish he would stop. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: String splitting with exceptions

2013-08-28 Thread Neil Cerutti
in_brackets = True elif c == ':': yield s[b:i] b = i+1 elif c == "]": in_brackets = False >>> print(list(dns_split(s))) ['foo.[DOM]', '', '[IP6::4361:6368:6574]', '600', ''] It'll gag on nested brackets (fixable with a counter) and has no error handling (requires thought), but it's a start. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: String splitting with exceptions

2013-08-28 Thread Neil Cerutti
,s) >> ['foo.[DOM]', '', '[IP6::4361:6368:6574]', '600', '', ''] >> >> I'm not sure why _your_ list only has one empty string at the end. > > I wondered that. Good point. My little parser fails on that, too. I

Re: python script to gather file links into textfile

2013-08-30 Thread Neil Cerutti
On 2013-08-30, david.d...@gmail.com wrote: > Hi, im looking for someone who can make a script that gathers > all file links from an url into a textfile, like this : > http://pastebin.com/jfD31r1x Michael Jackson advises you to start with the man in the mirror. -- Neil Cerutti

sax.handler.Contenthandler.__init__

2013-08-30 Thread Neil Cerutti
t happens, ContentHandler.__init__ isn't empty, so the above code could fail if the parser isn't prepared for _locator to be undefined. Is the above code is an acceptable idiom? -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: semicolon at end of python's statements

2013-09-03 Thread Neil Cerutti
t = stack.enter_context(open('another_file', 'w')) It ain't beautiful, but it unfolds the nesting and gets rid of the with statement's line-wrap problems. -- Neil Cerutti -- https://mail.python.org/mailman/listinfo/python-list

Re: semicolon at end of python's statements

2013-09-03 Thread Neil Cerutti
On 2013-09-03, Neil Cerutti wrote: > 3.2 and above provide contextlib.ExitStack, which I just now > learned about. > > with contextlib.ExitStack() as stack: > _in = stack.enter_context(open('some_file')) > _out = stack.enter_context(open('another_file&#x

Re: Could someone please paraphrase this statement about variables and functions in Python?

2013-09-05 Thread Neil Cerutti
t more knowledge of what it's referring to. > However this looks like something that's too important to > overlook. It's not ambiguous, self-contradictory or incomplete. But it's very densely packed with information; perhaps it's too complete. > I can tell it&#x

Re: Newbie question related to Boolean in Python

2013-09-05 Thread Neil Cerutti
which > means the loop will continue instead of cancelling it. > > Thanks in advance for spending your time to answer my question. Your logic looks OK, but the indentation on your code is screwy. It should not compile like that. There may be indentation errors, but I don't want to ma

<    1   2   3   4   5   6   7   8   9   10   >