Re: PEP8 79 char max

2013-09-06 Thread Neil Cerutti
, then requiring external > the line-renumbering utilities that AppleSoft BASIC required > :-S Though its graphics and sound were far inferior, as a C64 user I was really jealous of the speed of the built-in Apple disk drives. The only programming I did on them was typing in some of the program

Re: how to trouble shoot - RuntimeError: Open Failed

2013-09-06 Thread Neil Cerutti
to begin. We can help better if you show some of your code; a minimal cut-down version that exhibits the error is ideal. Are you literally getting a RuntimeError? That would be weird. -- Neil Cerutti -- https://mail.python.org/mailman/listinfo/python-list

Re: Language design

2013-09-11 Thread Neil Cerutti
assert len(elts) == 0 > elt = elts[0] I'm confused. Your rewrite looks like an assertion error or an IndexError. -- Neil Cerutti -- https://mail.python.org/mailman/listinfo/python-list

Re: Language design

2013-09-12 Thread Neil Cerutti
gt; I have one more: > > Dictionaries should iterate over their items instead of their keys. > > Looking forward to contrary opinions. Consider the 'in' operator. -- Neil Cerutti -- https://mail.python.org/mailman/listinfo/python-list

Re: Language design

2013-09-12 Thread Neil Cerutti
return fn(x,y) > ... return do_stuff > > I understand that python is not a functional language, but it > frustrates me at times. >>> import operator >>> equal = get_do_stuff(operator.eq)(7, 7.0) True -- Neil Cerutti -- https://mail.python.org/mailman/listinfo/python-list

Re: Stripping characters from windows clipboard with win32clipboard from excel

2013-09-13 Thread Neil Cerutti
re used to be good reasons for trying to leave some extra room >> >> on the clipboard and avoid reallocating the block but I thought that was >> >> over a long time ago. >> >> >> >> To strip NULs off the end of the string use

Re: Python GUI?

2013-09-13 Thread Neil Cerutti
is keyboard, Till is fingers were bloody stumps, And the very last words that were entered in his .blog were: GUI Builders are for chumps, Lord, Lord! Those GUI builders are for chumps. -- Neil Cerutti -- https://mail.python.org/mailman/listinfo/python-list

Re: Language design

2013-09-18 Thread Neil Cerutti
ot indentation - so we're > talking more like REXX than Python. In fact, it's not uncommon > for poetry to be laid out on a single line with slashes to > divide lines: There's lots of poetry with significant indentation, though. Imbuing the shape of the text on the page with significance is a thing. -- Neil Cerutti -- https://mail.python.org/mailman/listinfo/python-list

Re: Language design

2013-09-18 Thread Neil Cerutti
On 2013-09-18, Chris Angelico wrote: > On Thu, Sep 19, 2013 at 12:57 AM, Neil Cerutti wrote: >> There's lots of poetry with significant indentation, though. >> Imbuing the shape of the text on the page with significance is a >> thing. > > And you can do that wit

Re: Language design

2013-09-18 Thread Neil Cerutti
On 2013-09-18, wxjmfa...@gmail.com wrote: >>>> 1and 0 > 0 >>>> 'a'or 1 > 'a' >>>> 5if True else 999 > 5 Curse you, FSR! Oh, wait... -- Neil Cerutti -- https://mail.python.org/mailman/listinfo/python-list

Re: Stripping characters from windows clipboard with win32clipboard from excel

2013-09-19 Thread Neil Cerutti
do a strlen() (or the > wide-character equivalent; I forget its name) on the results. Python can't really know if you're pasting text or a screenshot or what. -- Neil Cerutti -- https://mail.python.org/mailman/listinfo/python-list

Re: Sphinx Doctest: test the code without comparing the output.

2013-09-23 Thread Neil Cerutti
cumenation any more but nothing stops you from examining the result in the next doctest and making yourself happy about it. >>> x = input("indeterminate:") >>> result = "'{}'".format(x)) >>> result.startswith("'") and result.endswith("'") True -- Neil Cerutti -- https://mail.python.org/mailman/listinfo/python-list

Re: Sphinx Doctest: test the code without comparing the output.

2013-09-23 Thread Neil Cerutti
On 2013-09-23, Neil Cerutti wrote: > Perhaps try the "advanced API" and define your oen > OutputChecker to add the feature that you need. > > Figuring out how to best invoke doctest with your modified > OutputChecker will take some digging in the source, probably > l

Re: Sphinx Doctest: test the code without comparing the output.

2013-09-23 Thread Neil Cerutti
nced API" and define your oen OutputChecker to add the feature that you need. Figuring out how to best invoke doctest with your modified OutputChecker will take some digging in the source, probably looking at doctest.testmod. I don't see an example in the docs. > Hope these examples helped to understand better what my problem > is. Yes, I think it's well-defined now. -- Neil Cerutti -- https://mail.python.org/mailman/listinfo/python-list

Re: What's the best way to extract 2 values from a CSV file from each row systematically?

2013-09-23 Thread Neil Cerutti
at least 1000 rows, an example: > > 0,0,KGD,0,DME,0,,0,0 > > The values I want to extract are KGD and DME (columns 3 and 5). Use the csv module. http://docs.python.org/2/library/csv.html -- Neil Cerutti -- https://mail.python.org/mailman/listinfo/python-list

Re: Newline interpretation issue with MIMEApplication with binary data, Python 3.3.2

2013-09-26 Thread Neil Cerutti
erated in general; they may be lost or converted to delimiters on some systems, and hence must not be relied on. So putting a raw CR in a binary chunk maybe be intolerable, and you need to use a different encoder. But I'm out of my element. -- Neil Cerutti -- https://mail.python.org/mailman/listinfo/python-list

Re: Understanding how is a function evaluated using recursion

2013-09-26 Thread Neil Cerutti
ll flatten on itself, as in the recursive version, because the stack frames do all the bookkeeping for you. CPython has a limited number of stack frames though, so the version above might be preferable for certain levels of nesting. [1] http://en.wiktionary.org/wiki/bikeshed -- Neil Cerutti -- https://mail.python.org/mailman/listinfo/python-list

Re: Understanding how is a function evaluated using recursion

2013-09-26 Thread Neil Cerutti
On 2013-09-26, Neil Cerutti wrote: > def flatten(seq): > > [1] http://en.wiktionary.org/wiki/bikeshed In that spirit, it occurs to me that given current Python nomenclature, 'flattened' would be a better name. -- Neil Cerutti -- https://mail.python.org/mailman/listinfo/python-list

Re: How to write in to already opened excel file by using openpyxl

2013-09-27 Thread Neil Cerutti
hat excel file and save that excel file Show more code, please. And please describe the error more fully. What did you hope to happen, and what happened instead? What have you tried so far? -- Neil Cerutti -- https://mail.python.org/mailman/listinfo/python-list

Re: unable to read combo boxes in excel by xlrd package in python

2013-09-27 Thread Neil Cerutti
no multi-select, etc.), and so it's possible a Visual Basic widget was used instead. That would leave the cell contents blank when read, as above. You will need to retrieve the value from the combo-box object directly somehow. -- Neil Cerutti -- https://mail.python.org/mailman/listinfo/python-list

Re: unable to read combo boxes in excel by xlrd package in python

2013-09-27 Thread Neil Cerutti
On 2013-09-27, Neil Cerutti wrote: > On 2013-09-27, somesh g wrote: >> Hi..there >> >> I want to read the combo box in excel by using "xlrd" but in >> the output it is showing empty message, its not reading the >> combo box can u guys help me how

Re: Handling 3 operands in an expression without raising an exception

2013-09-27 Thread Neil Cerutti
just want to shove the food directly into my stomach. -- Neil Cerutti -- https://mail.python.org/mailman/listinfo/python-list

Re: Handling 3 operands in an expression without raising an exception

2013-09-30 Thread Neil Cerutti
poker, yes? > > I'm going to go out on a limb and suggest that such a suggestion is > outside what people generally consider acceptable on this list. It's reassuring that even a guy like Nikos has his White Knights. -- Neil Cerutti -- https://mail.python.org/mailman/listinfo/python-list

Re: Handling 3 operands in an expression without raising an exception

2013-09-30 Thread Neil Cerutti
nd > the frustration that leads people to want him to suffer great > pain. I don't want him to suffer great pain, but it would please me if it were possible to annoy him in some way. Like maybe with the sound of a mosquito. B! BzZ! -- Neil Cerutti -- https://mail.python.org/mailman/listinfo/python-list

Re: Functional Programming and python

2013-09-30 Thread Neil Cerutti
ry of callbacks, with the simple functions defined in-line and the more complex functions defined just before that and referenced instead. -- Neil Cerutti -- https://mail.python.org/mailman/listinfo/python-list

Re: Functional Programming and python

2013-10-01 Thread Neil Cerutti
On 2013-10-01, Steven D'Aprano wrote: > On Mon, 30 Sep 2013 18:36:28 +0000, Neil Cerutti quoted: > >> Why can??t lambda forms contain statements? > > Gah! Please fix your news client! (I see you're using slrn.) > The \x92 bytes found in your message are ap

Re: JUST GOT HACKED

2013-10-02 Thread Neil Cerutti
me value in telling someone why you might killfile them. But actual *plonks* are, I think, manifestation of spotlight syndrome. -- Neil Cerutti -- https://mail.python.org/mailman/listinfo/python-list

Re: Rounding off Values of dicts (in a list) to 2 decimal points

2013-10-02 Thread Neil Cerutti
gt; v = ceil(v*100)/100.0 [*] You're binding v to a new float object here, but not modifying y. Thus, this code will have no effect on y. You need to assign to y[k] here instead. for k, v in d.items(): y[k] = round(v, 2) > return Bare returns are not u

Re: Tail recursion to while iteration in 2 easy steps

2013-10-03 Thread Neil Cerutti
lso it means code for this modified Python wouldn't run on > other non-modified interpreters, but it is at least > theoretically possible without breaking Python's assumptions. In any case it's so easy to implement yourself I'm not sure there's any point. -- Neil Cerutti -- https://mail.python.org/mailman/listinfo/python-list

Re: Rounding off Values of dicts (in a list) to 2 decimal points

2013-10-03 Thread Neil Cerutti
c": 10.0, "d": 10.0}, {"a": 90.0, "b": 0.0, "c": 0.0, "d": > 10.0}] > > However, at the URL, the values show up as 90.43278694123 You'll need to convert them to strings yourself before submitting them, by using % formatting or str.format. -- Neil Cerutti -- https://mail.python.org/mailman/listinfo/python-list

Re: Re for Apache log file format

2013-10-08 Thread Neil Cerutti
= re.compile( r"""(?P\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})\s+ (?P\-)\s+ (?P\-)\s+ (?P\[(.*?)\])\s+# You can even insert comments. (?P\"(.*?)\")\s+ (?P\d{3})\s+ (?P\d+)\s+ (?P\"\")\s+ (?P\((.*?)\))""", re.VERBOSE) -- Neil Cerutti -- https://mail.python.org/mailman/listinfo/python-list

Re: Encoding of surrogate code points to UTF-8

2013-10-08 Thread Neil Cerutti
to store unchecked UTF-16 such as Windows filenames as UTF-8. It is also incompatible with CESU encoding (described below). So Python's interpretation is conformant, though not without some disadvantages. In any case, "\ud800\udc01" isn't a valid unicode string. In a perfect world it would automatically get converted to '\u00010001' without intervention. -- Neil Cerutti -- https://mail.python.org/mailman/listinfo/python-list

Re: Encoding of surrogate code points to UTF-8

2013-10-08 Thread Neil Cerutti
On 2013-10-08, Neil Cerutti wrote: > In any case, "\ud800\udc01" isn't a valid unicode string. In a > perfect world it would automatically get converted to > '\u00010001' without intervention. This last paragraph is erroneous. I must have had a typo in my te

Re: Encoding of surrogate code points to UTF-8

2013-10-09 Thread Neil Cerutti
clusive way"? Ned, pay no attention to the person whalopping that dead horse. -- Neil Cerutti -- https://mail.python.org/mailman/listinfo/python-list

Re: I am never going to complain about Python again

2013-10-10 Thread Neil Cerutti
type (except in the case of complex numbers (Ha!)). r == c is equivalent to r == abs(c), which returns the magintude of the complex number. I wonder why it was deemed reasonable to do that but not for the float constructor to do the same, or even int. > BTW, one of the earliest things tha

Re: I am never going to complain about Python again

2013-10-10 Thread Neil Cerutti
On 2013-10-10, MRAB wrote: > On 10/10/2013 16:57, Rotwang wrote: >> On 10/10/2013 16:51, Neil Cerutti wrote: >>> [...] >>> >>> Mixed arithmetic always promotes to the wider type (except in >>> the case of complex numbers (Ha!)). >>> >

Re: I am never going to complain about Python again

2013-10-10 Thread Neil Cerutti
On 2013-10-10, Ian Kelly wrote: > On Thu, Oct 10, 2013 at 11:48 AM, Neil Cerutti wrote: >> Woah. I thought I was going by what the docs say: >> >> Python fully supports mixed arithmetic: when a binary >> arithmetic operator has operands of different numeric types

Re: I am never going to complain about Python again

2013-10-10 Thread Neil Cerutti
On 2013-10-10, Oscar Benjamin wrote: > On 10 October 2013 18:48, Neil Cerutti wrote: >> I guess the "if appropriate" part eluded my eye. When *is* it >> appropriate? Apparently not during an equal test. >> >>>>> 5.0 == abs(3 + 4j) >> False >

Re: I am never going to complain about Python again

2013-10-11 Thread Neil Cerutti
On 2013-10-11, Steven D'Aprano wrote: > On Thu, 10 Oct 2013 17:48:16 +0000, Neil Cerutti wrote: > >> >>> 5.0 == abs(3 + 4j) >> False > > Did you maybe accidentally rebind abs? If not, what version of > Python are you using? Honestly, I think I got m

Re: basic maze problem with turtle

2013-10-14 Thread Neil Cerutti
dgment. https://mail.python.org/pipermail/python-list/ -- Neil Cerutti -- https://mail.python.org/mailman/listinfo/python-list

Re: skipping __init__ and using exploiting a class member instead

2013-10-21 Thread Neil Cerutti
and template specialization, for example; you get a generic interface with a decoupled implementation which can be optimized for specific types at need. -- Neil Cerutti -- https://mail.python.org/mailman/listinfo/python-list

Re: Class construction

2013-10-22 Thread Neil Cerutti
Python Language Reference 8.7 Class definitions. Here's a link to the 3.3 version of those docs: http://docs.python.org/3.3/reference/compound_stmts.html#class-definitions -- Neil Cerutti -- https://mail.python.org/mailman/listinfo/python-list

Re: Python Front-end to GCC

2013-10-22 Thread Neil Cerutti
s, not simply to all-bits zero as (I think) C does. This isn't as great a feature as it seems, since the zero value for some built in types, e.g., map, is unusable without manual construction. In addition, you can't define a zero value for your own types. -- Neil Cerutti -- https://mail.python.org/mailman/listinfo/python-list

Re: Python Front-end to GCC

2013-10-22 Thread Neil Cerutti
>> global) and you'll see the difference. > > Ah, that makes sense. Thanks to everyone who corrected my > misunderstanding. > > Well, actually, no it doesn't. I wonder why C specifies such > behaviour? Why would you want non-global arrays to be filled > wit

Re: Python Front-end to GCC

2013-10-22 Thread Neil Cerutti
GCC into an executable. What executable would GCC compile from a program that matched this grammar? spamgram = spam1, { ', ', more_spam }, '.' spam1 = 'Spam' more_spam = spam, { ', ', spam } spam = 'spam' -- Neil Cerutti -- https://mail.python.org/mailman/listinfo/python-list

Re: Python Front-end to GCC

2013-10-22 Thread Neil Cerutti
On 2013-10-22, Piet van Oostrum wrote: > Neil Cerutti writes: >> Context-sensitive grammars can be parse, too. > > That's not English. Do you mean "parsed"? Thanks, yes, I meant parsed. > But context-sentitive grammars cannot be specified by BNF. Yes

Re: Python Front-end to GCC

2013-10-22 Thread Neil Cerutti
On 2013-10-22, Mark Lawrence wrote: > On 22/10/2013 20:27, Neil Cerutti wrote: >> On 2013-10-22, Piet van Oostrum wrote: >>> Neil Cerutti writes: >>>> Context-sensitive grammars can be parse, too. >>> >>> That's not English. Do you mean &q

Re: Will Python 3.x ever become the actual standard?

2013-10-23 Thread Neil Cerutti
On 2013-10-23, David wrote: > On 23 October 2013 22:57, wrote: >> >> a LARGE number of Python programmers has not even bothered learning version >> 3.x. > > OMG. Please provide their names. We'll send Doug & Dinsdale. I can send Mr. Wendt and Mr. Kid

Re: Will Python 3.x ever become the actual standard?

2013-10-23 Thread Neil Cerutti
second class OS? Ducks and runs for cover :) They usually don't. Users of most distributions have an awesome device called a package manager. -- Neil Cerutti -- https://mail.python.org/mailman/listinfo/python-list

Re: Cookie fucking problem

2013-10-28 Thread Neil Cerutti
ll. Yours is not to reason why, Jamison. You've left out the body of the letter! ... Fine. Send it that way, and tell them the body will follow. -- Neil Cerutti -- https://mail.python.org/mailman/listinfo/python-list

Re: Python Front-end to GCC

2013-10-28 Thread Neil Cerutti
o >>> babel. >> >> I think you do him a disservice. I'm pretty sure it's genuine, >> bona-fide, 24K, dyed-in-the-wool, 99 and 44/100 pure babble. > > I think it's even better than that... maybe even 28.8K! >From my own bailiwick I'd say it's Grade A Medium Amber. -- Neil Cerutti -- https://mail.python.org/mailman/listinfo/python-list

Re: Cookie fr*cking problem

2013-10-29 Thread Neil Cerutti
On 2013-10-29, Steven D'Aprano wrote: > On Mon, 28 Oct 2013 13:20:17 +0000, Neil Cerutti wrote: > >> On 2013-10-27, Ben Finney wrote: >>> I have no particular objection to you responding to those >>> instances of bad behaviour that I've omitted. >>

Re: how to avoid checking the same condition repeatedly ?

2013-10-29 Thread Neil Cerutti
ed about performance that you're > willing to trade clarity for it, you shouldn't be using Python > in the first place. When you detect a code small, as Wolfgang did, e.g., "I'm repeating the same exact test condition in several places," you should not simply ignore it

Re: Help with guessing game :D

2013-10-29 Thread Neil Cerutti
houldn't be embroiled in the morass of interactive programming. -- Neil Cerutti -- https://mail.python.org/mailman/listinfo/python-list

Re: First day beginner to python, add to counter after nested loop

2013-10-29 Thread Neil Cerutti
factor++; >square=Math.pow(factor,exponent); > } > factor--; > document.write(factor," "); > square=Math.pow(factor,exponent); > number=number-(factor*factor); > square=1; > factor=1; > } > document.wr

Re: First day beginner to python, add to counter after nested loop

2013-10-29 Thread Neil Cerutti
ython operators and identifiers. > square=1; > factor=1; > print("+",number); > return A bare return at the end of a Python function is not needed. All functions return None if they fall off the end. -- Neil Cerutti -- https://mail.python.org/mailman/listinfo/python-list

Re: Using "with open(filename, 'ab'):" and calling code only if the file is new?

2013-10-30 Thread Neil Cerutti
except IOError: pass with open(self.full_path, 'b') as infile: # etc... shutil.copy(tempname, self.output_csv) This avoids clobbering output_csv unless new data is succesfully written. I believe TempDirectory isn't available in Python 2, so some other way of creating that path will be needed, and I'm too lazy to look up how. ;) -- Neil Cerutti -- https://mail.python.org/mailman/listinfo/python-list

Re: Error Testing

2013-10-31 Thread Neil Cerutti
than that characterization accords. -- Neil Cerutti -- https://mail.python.org/mailman/listinfo/python-list

Re: Error Testing

2013-10-31 Thread Neil Cerutti
On 2013-10-31, rusi wrote: > On Thursday, October 31, 2013 8:50:27 PM UTC+5:30, Neil Cerutti wrote: >> wrote: >> > This suggests that Pascal went against established practice. >> > This is false. FORTRAN used = and that was a mistake caused by >> > the langua

Re: telnet problem

2013-11-01 Thread Neil Cerutti
On 2013-11-01, wrote: > hello every expert, > When I use telnetlib to send a command, I meet some troubles, I > have read some documents about telnetlib and modify many times, > but the script doesn't work all the time. What goes wrong? -- Neil Cerutti -- https://mail.p

Re: how to find out utf or not

2013-11-05 Thread Neil Cerutti
source bytes. Unless there's some context I'm not privy to. u'x' is (hopefully) decoded already, but the encoding of 'x' is unknown. -- Neil Cerutti -- https://mail.python.org/mailman/listinfo/python-list

Re: To whoever hacked into my Database

2013-11-07 Thread Neil Cerutti
COWardly :-) >> >> Well, maybe the issue is MOOt. > > Ugh, if only these puns were like CALF-way funny... > > *dives for cover* Phew! I can't stomach stomach stomach this digression. -- Neil Cerutti -- https://mail.python.org/mailman/listinfo/python-list

Re: To whoever hacked into my Database

2013-11-07 Thread Neil Cerutti
> convention for the start of your signature, and many people and UAs > will ignore text after it.) It's '-- ', with a space after, to be precise. But I like it the way he's doing it! His messages are greatly improved from where I'm sitting.. -- Neil Cerutti -- https://mail.python.org/mailman/listinfo/python-list

Re: Adding 'download' column to existing 'visitors' table (as requested)

2013-11-07 Thread Neil Cerutti
rage scheme, you can't. So by storing the data this way, you are promising yourself that you'll never need to write that query, or at least, you won't need to do it very often. > I still don't know why you push me to create an extra table > instead. Because

Re: To whoever hacked into my Database

2013-11-08 Thread Neil Cerutti
On 2013-11-08, ru...@yahoo.com wrote: > Just wanted to let you know that not everybody here is an > asshole. It is just that assholes, by their nature, are the > loudest. Hey man, pass that over! -- Neil Cerutti -- https://mail.python.org/mailman/listinfo/python-list

Re: New user's initial thoughts / criticisms of Python

2013-11-11 Thread Neil Cerutti
but I haven't tried it for that. > I'd use this select if it was in Python, but I don't see much > need for it. Same here. Perhaps the real value of a switch is that it seems to be a more natural way of thinking about execution. The caveat to that is most *actual* switch implementations are a mess. -- Neil Cerutti -- https://mail.python.org/mailman/listinfo/python-list

Re: question about speed of sequential string replacement vs regex or

2011-09-28 Thread Neil Cerutti
rings down to one string is a lot > less common. So, let's have some real-world use cases and then > we can talk recommendations. I'd like to know what "string replacement" is supposed to mean in the context of Python. -- Neil Cerutti "A politician is an arse

Re: Benefit and belief

2011-09-30 Thread Neil Cerutti
ng right, proper and correct been so thoroughly celebrated. Except perhaps when my C++ program compiles without warnings. That's pretty good, too. -- Neil Cerutti "A politician is an arse upon which everyone has sat except a man." e. e. cummings -- http://mail.python.org/mailman/listinfo/python-list

Re: Benefit and belief

2011-09-30 Thread Neil Cerutti
is night," you are making an assertion about a position on the surface of the earth and its relationship to the sun. If you are not discussing a specific a position on the Earth, then you cannot make a meaningful assertion about night or day at all. Night and Day are not qualities of the entir

Re: Suggested coding style

2011-09-30 Thread Neil Cerutti
with feature X type question is > normally "gnus" - although I don't know what "Gmail-like style" is. slrn. Is good. -- Neil Cerutti "A politician is an arse upon which everyone has sat except a man." e. e. cummings -- http://mail.python.org/mailman/listinfo/python-list

Re: Both Python 2.5.2 and 2.7.2 flop the same way under Win 7

2011-11-18 Thread Neil Cerutti
Options Click the File Types tab in the Folder Options menu. There will be an upper view with registered filed types, and some buttons below far making changes to them. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: How to: Coordinate DictReader and Reader for CSV

2011-11-21 Thread Neil Cerutti
those numbers, you want: [...] print data['0'] print data['1'] print data['2'] print data['3'] print data['4'] [...] -- Neil Cerutti "This room is an illusion and is a trap devisut by Satan. Go ahead and dauntlessly! Make rapid progres!" --Ghosts 'n Goblins -- http://mail.python.org/mailman/listinfo/python-list

Re: How to: Coordinate DictReader and Reader for CSV

2011-11-21 Thread Neil Cerutti
line writer.writerow({f: f for n in fields}) for record in reader: # Change a few fields # [...] writer.writerow(record) -- Neil Cerutti "This room is an illusion and is a trap devisut by Satan. Go ahead and dauntlessly! Make rapid progres!" --Ghost

Re: How to: Coordinate DictReader and Reader for CSV

2011-11-21 Thread Neil Cerutti
On 2011-11-21, Neil Cerutti wrote: > On 2011-11-21, ray wrote: >> Is there a way to capture the keys outside of the for loop so >> when the for loop is entered, only data is extracted? > > I have sometimes done the following type of thing, since > DictReader doesn't

Re: correct usage of a generator?

2011-11-28 Thread Neil Cerutti
e you might need that won't work. The following assumes you'll need less than 1000. counter = itertools.count() ... with open("%03d" % counter.next(), "w") as the_next_file: ... My Python < 3.0 is rusty, so sorry if I messed that up. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: Using the Python Interpreter as a Reference

2011-11-28 Thread Neil Cerutti
always held with the "anti-functional style conspiracy" interpretation of Python's lambda expressions. They were added but grudgingingly, made weak on purpose to discourage their use. -- Neil Cerutti "This room is an illusion and is a trap devisut by Satan. Go a

Re: Using the Python Interpreter as a Reference

2011-11-28 Thread Neil Cerutti
On 2011-11-28, Gregory Ewing wrote: > Neil Cerutti wrote: >> I've always held with the "anti-functional style conspiracy" >> interpretation of Python's lambda expressions. They were added >> but grudgingingly, made weak on purpose to discourage their >

Re: Total newbie question: Best practice

2011-11-29 Thread Neil Cerutti
for each part of the program. The resultant refactored programs are much easier to test, read and maintain. TLDR: "Called-only-once" functions like main are useful as documentation, hooks for testing, and for unraveling a snarl of global variables. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: Questions about LISP and Python.

2011-12-07 Thread Neil Cerutti
On 2011-12-07, Terry Reedy wrote: > It does not pretend that surrounding statements with > parentheses turns them into expressions. > ;-) I like being in a sexpression. Aww YEH! -- (Neil Cerutti) -- http://mail.python.org/mailman/listinfo/python-list

Re: Getting the current directory path and the path where python script is saved

2011-12-13 Thread Neil Cerutti
os.path.basename(sys.argv[0]). -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: [OT] Quick intro to C++ for a Python and C user?

2011-12-20 Thread Neil Cerutti
starting point for learning pointers, though since you already know C that won't do you as much good. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: [OT] Quick intro to C++ for a Python and C user?

2011-12-21 Thread Neil Cerutti
hen you could as well write C++ compatible C and be pretty happy with the results. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: [OT] Quick intro to C++ for a Python and C user?

2011-12-21 Thread Neil Cerutti
On 2011-12-21, Grant Edwards wrote: > On 2011-12-21, Neil Cerutti wrote: >> On 2011-12-20, Paul Rubin wrote: >>> Grant Edwards writes: >>>> Oops. I should have mentioned this is for embedded systems >>>> programming so templates in general (and ST

Re: [OT] Quick intro to C++ for a Python and C user?

2011-12-22 Thread Neil Cerutti
7;m only half joking... :) > > Half joking, indeed. I happen to know for a fact that there > are *fourteen* people on the planet who understand it. One of its greatest contributions to computer science were Glassbarrow's C++ puzzles. They likely couldn't have been as ch

Re: what does 'a=b=c=[]' do

2011-12-23 Thread Neil Cerutti
On 2011-12-23, Neil Cerutti wrote: > Is the misfeature that Python doesn't evaluate the default > argument expression every time you call the function? What > would be the harm if it did? ...you know, assuming it wouldn't break existing code. ;) -- Neil Cerutti -- htt

Re: what does 'a=b=c=[]' do

2011-12-23 Thread Neil Cerutti
ing >> multiple inheritence was a bug and asking it to be removed. > > Both of these could arguably be called misfeaures, but not > bugs. Is the misfeature that Python doesn't evaluate the default argument expression every time you call the function? What would be

Re: Early and late binding [was Re: what does 'a=b=c=[]' do]

2011-12-23 Thread Neil Cerutti
On 2011-12-23, Steven D'Aprano wrote: > On Fri, 23 Dec 2011 13:13:38 +0000, Neil Cerutti wrote: >> On 2011-12-23, Neil Cerutti wrote: >>> Is the misfeature that Python doesn't evaluate the default >>> argument expression every time you call the function?

Re: .format vs. %

2012-01-03 Thread Neil Cerutti
formatting should not > be deprecated at all. When it becomes necessary, it's possible to optimize it by hoisting out the name lookups. ... outfil_write = outfil.write append_newline = "{}\n".format ... outfil_write(append_newline(t)) ... -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: .format vs. %

2012-01-03 Thread Neil Cerutti
On 2012-01-03, Stefan Krah wrote: > Neil Cerutti wrote: >> > In the real-world telco benchmark for _decimal, replacing the >> > single line >> > >> > outfil.write("%s\n" % t) >> > >> > with >> > >> >

Re: .format vs. %

2012-01-03 Thread Neil Cerutti
On 2012-01-03, Neil Cerutti wrote: > On 2012-01-03, Stefan Krah wrote: >> Neil Cerutti wrote: >>> > In the real-world telco benchmark for _decimal, replacing the >>> > single line >>> > >>> > outfil.write("%s\n"

Re: python philosophical question - strong vs duck typing

2012-01-03 Thread Neil Cerutti
words in the registry. You still have to copy of the text, but only once. The C++ implementation starts to smell sort of like Python. ;) -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: .format vs. %

2012-01-03 Thread Neil Cerutti
100 -s "n=7.92" "'%s' % n" 100 loops, best of 3: 0.965 usec per loop C:\WINDOWS>python -m timeit -n 100 -s "n=7.92" "'{}'.format(n)" 100 loops, best of 3: 1.17 usec per loop -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: replacing __dict__ with an OrderedDict

2012-01-09 Thread Neil Cerutti
an idea that is usually a bad practice, then it should be challenged. The possible broken-nose of a questioner is a small price to pay for the education of the peanut gallery. If a questioner does not wish to defend what they are doing, he or she has that right, of course. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: contextlib.contextmanager and try/finally

2012-01-11 Thread Neil Cerutti
generator in an object with __enter__ and __exit__ methods for you. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: copy on write

2012-01-13 Thread Neil Cerutti
pecifically, it confuses > almost everyone the first time they encounter it that "a += b" > is not the same as "a = a + b". If you've ever implemented operator=, operator+, and operator+= in C++ you'll know how and why they are different. A C++ programmer would be wondering how either can work on immutable objects, and that's where Python's magical rebinding semantics come into play. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: copy on write

2012-01-13 Thread Neil Cerutti
Pike. >> >> (With apologies to Larry Wall) > > Were one inclined to troll a bit, one might be tempted to claim > that using C++ is prima facie evidence of not understanding > C++. > > Not that I would ever claim something inflamitory like that... On the Python newsgro

Re: copy on write

2012-01-13 Thread Neil Cerutti
On 2012-01-13, Evan Driscoll wrote: > On 01/13/2012 10:54 AM, Neil Cerutti wrote: >> If you've ever implemented operator=, operator+, and operator+= >> in C++ you'll know how and why they are different. > > At the same time, you'd also know that that implementi

Re: Opinion on best practice...

2013-02-05 Thread Neil Cerutti
ent option for writing shell scripts, particularly if your shell is cmd.exe. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: Opinion on best practice...

2013-02-06 Thread Neil Cerutti
On 2013-02-05, Grant Edwards wrote: > On 2013-02-05, Neil Cerutti wrote: >> On 2013-02-05, Walter Hurry wrote: >>>> Sorry, I'm a Linux guy. I have no clue what that means. >>> >>> Hooray for common sense! Python is great, but it's silly to us

Re: First attempt at a Python prog (Chess)

2013-02-15 Thread Neil Cerutti
On 2013-02-15, Oscar Benjamin wrote: > if score > best_score or best_score is None: You need the None check first to avoid an exception from the comparison. if best_score is None or score > best_score: -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

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