Re: First python program, syntax error in while loop

2013-05-06 Thread Neil Cerutti
On 2013-05-06, Mark Lawrence wrote: > On 06/05/2013 13:06, Neil Cerutti wrote: >> On 2013-05-03, John Gordon wrote: >>> In Neil Cerutti >>> writes: >>> >>>> Not quite yet. Players who guess correctly on the fifth try don't >>>>

Re: help on Implementing a list of dicts with no data pattern

2013-05-09 Thread Neil Cerutti
> highway_dict['lanes'], highway_dict['state'], > highway_dict['limit(mph)'] = lanes, state, limit_values > queue_row.append(highway_dict) Can you provide a short example of input and what you had hoped to see in the lists and dicts at the end? -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: Style question -- plural of class name?

2013-05-09 Thread Neil Cerutti
postrophe for pluralisation. If there's no chance for confusion between a class named FooEntry and another named FooEntries, then the first attempt seems best. Pluralize a class name by following the usual rules, e.g., "strings" and "ints". -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: Style question -- plural of class name?

2013-05-09 Thread Neil Cerutti
On 2013-05-09, Jussi Piitulainen wrote: > Neil Cerutti writes: >> If there's no chance for confusion between a class named >> FooEntry and another named FooEntries, then the first attempt >> seems best. Pluralize a class name by following the usual >> rules, e.g.

Re: help on Implementing a list of dicts with no data pattern

2013-05-10 Thread Neil Cerutti
pected output from it, chances are you aren't ready to start writing code. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: Python for philosophers

2013-05-13 Thread Neil Cerutti
, who taught that heavier objects fall faster, was walking past. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: [Off topic] Software epigrams

2013-05-13 Thread Neil Cerutti
reflection it speciously inserts the word "irrelevant" in order to avoid stating a tautology: A programming language is low level when its programs require attention to low level details. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: [Off topic] Software epigrams

2013-05-15 Thread Neil Cerutti
On 2013-05-13, F?bio Santos wrote: > > On 13 May 2013 19:48, "Neil Cerutti" wrote: >> >> On 2013-05-13, Skip Montanaro wrote: >> >> 8. A programming language is low level when its programs >> >> require attention to the irrelevant. &g

Re: [Off topic] Software epigrams

2013-05-15 Thread Neil Cerutti
read I hope I don't have to till a garden, plant the wheat, harvest the wheat, and grind the wheat. But gardening is relevant to bread baking weather or not I do it. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: [Off topic] Software epigrams

2013-05-16 Thread Neil Cerutti
n the level of problem for which a programming language is most appropriate. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: any cherypy powred sites I can check out?

2013-05-17 Thread Neil Cerutti
Everybody." I didn't write it myself--I wrote it some asshole.' --Steve Martin -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: A computer programmer, web developer and network admin resume

2013-05-23 Thread Neil Cerutti
On 2013-05-22, Tim Chase wrote: > On 2013-05-22 01:15, i...@databaseprograms.biz wrote: >> A computer programmer, web developer and network administrator > > ...walk into a bar... > > So what's the punchline? "Ow." Get it? "Ow." -- Neil Cerut

Re: Non-identifiers in dictionary keys for **expression syntax

2013-05-23 Thread Neil Cerutti
the definition. Where are you perceiving wiggle room? -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: Utility to locate errors in regular expressions

2013-05-24 Thread Neil Cerutti
ograms like the remake of Dawn of the GREP, just aren't as scary. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: Polymoprhism question

2013-05-24 Thread Neil Cerutti
__name__: cls for cls in (A, B)} ArgType = classes[sys.agrv[1]] arg = ArgType() arg.in("test") arg.out("test") -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: Python #ifdef

2013-05-28 Thread Neil Cerutti
m Python 2 and 3 >> in a single file. >> >> Is that possible? How? You need sys.version_info. For more, see http://python3porting.com/noconv.html -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: Short-circuit Logic

2013-05-30 Thread Neil Cerutti
r. I propose borrowing the concept of significant digits from the world of Physics. The above has at least three significant digits. With that scheme x would approximately equal 17.3 when 17.25 <= x < 17.35. But I don't see immediately how to calculate 17.25 and 17.35 from 17.3, 00.1 an

Re: py_compile vs. built-in compile, with __future__

2013-06-11 Thread Neil Cerutti
iting the modified module back to a file so that I can still > use py_compile.compile() to byte compile that code. You would use StringIO instead of writing a temp file. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: A certainl part of an if() structure never gets executed.

2013-06-12 Thread Neil Cerutti
27;=' not in month and '=' not in year: > > It'd be courteous to acknowledge those who made that > suggestion, most notably alex23 who posted it in almost that > exact form. Also, I wish he would stop fudging his From info. I've got something like 8 entries fo

Re: py_compile vs. built-in compile, with __future__

2013-06-12 Thread Neil Cerutti
On 2013-06-11, dhyams wrote: >> You would use StringIO instead of writing a temp file. > > I don't think that would work...py_compile takes a filename as > input, not a file object. Dang. Sorry for the misinfo. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: A certainl part of an if() structure never gets executed.

2013-06-12 Thread Neil Cerutti
ch you didn't tell us here, including which database you are >> using. > > Are you guys _still_ on Nikos hook? > > [No, I don't really think he's trolling, but it would be really > impressive if he were.] He's definitely trolling. I can't think of any other reason to make it so hard to kill-file himself. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: Turnign greek-iso filenames => utf-8 iso

2013-06-12 Thread Neil Cerutti
On 2013-06-12, Mark Lawrence wrote: > On 12/06/2013 13:42, wrote: >> >> Something you want me to try? > > I'd suggest suicide but that would no doubt start another > stream of questions along the lines of "How do I do it?". hi. I loopet rope aroung and jumped, but br

Re: A certainl part of an if() structure never gets executed.

2013-06-13 Thread Neil Cerutti
On 2013-06-12, Zero Piraeus wrote: > On 12 June 2013 10:55, Neil Cerutti wrote: >> >> He's definitely trolling. I can't think of any other reason to >> make it so hard to kill-file himself. > > He's not a troll, he's a help vampire: > &g

Re: Creating a Super Simple WWW Link, Copy, & Paste into Spreadsheet Program

2013-06-14 Thread Neil Cerutti
r is, much, much simpler. Unless there's some non-trivial need to use Excel directly I strongly recommend exporting as csv and using the csv module. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: Don't feed the troll...

2013-06-14 Thread Neil Cerutti
worst of all, there's none of the closure or vicarious catharsis that usually comes from a well-designed educational transaction. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: My son wants me to teach him Python

2013-06-14 Thread Neil Cerutti
ts in GUI interface have built-in stengths and weaknesses. I was going to write something about them earlier, but I got bogged down when I thought of the issue of accessibilty, which overtakes any such discussion. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: A Beginner's Doubt

2013-06-19 Thread Neil Cerutti
PIL for this project, instead of PyGame. I have not personally used PyGame, but my guess is it will be much harder to create a reasonable GUI with PyGame than with tkinter. But I do not know how difficult this project will be will be even using the libraries of least resistance. The GUI you propose is very simple, except possibly for the dragging and dropping, which I've not tried and might be hairy. Moreover, I have not seriously used PIL and I don't even know if it supports Python 3. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: Problem with the "for" loop syntax

2013-06-20 Thread Neil Cerutti
acket, quote or colon. So if you press enter and the autoindent is unexpected, don't just press space or backspace to fix it. It's usually a sign of an earlier syntax error, so look for that first. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: Problem with the "for" loop syntax

2013-06-21 Thread Neil Cerutti
On 2013-06-20, Cameron Simpson wrote: > On 20Jun2013 13:55, Neil Cerutti wrote: >| On 2013-06-20, Joshua Landau wrote: >| > On 20 June 2013 04:11, Cameron Simpson wrote: >| >> Also, opening-and-not-closing a set of brackets is almost the >| >> only way in Pyt

Re: Default Value

2013-06-21 Thread Neil Cerutti
rrectly, you have to have mastered three separate Python concepts. 1. How name-binding works. 2. How argument passing works, i.e., via name-binding. 3. When default arguments are evaluated. 4. The Python object model. OK, you have to know four things. Curses! I'll come in again. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: Looking for a name for a deployment framework...

2013-06-24 Thread Neil Cerutti
ar. If you're thinking of >> this as a fabric replacement, I would go with cloth, textile, material, >> gabardine, etc. > > Snakeskin? Oh, I see that's already taken. :-( Most things are taken nowadays. A short nonsense-word is best. Something like "Folaf". Yeah, it doesn't spark the imagination, but it's easy to find, if not to remember. Well, not "Folaf." That seems to be an African style restaurant in L.A. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: Is this PEP-able? fwhile

2013-06-26 Thread Neil Cerutti
armful like a > religious edict. The one-exit-point rule is helpful for tracking entry and exit invariants. But in my view it shouldn't be followed when it makes code worse. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: Stupid ways to spell simple code

2013-07-01 Thread Neil Cerutti
= { True: lambda: print("No name longer than 20 letters."), False: lambda: True, }[len(name) > 20]() Much better. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: python adds an extra half space when reading from a string or list

2013-07-01 Thread Neil Cerutti
s are not only for spam. I filter out anything I believe I won't want to see. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: Regular expression negative look-ahead

2013-07-02 Thread Neil Cerutti
return true for only > these tables: > MY_TABLE > YOUR_TABLE Use the "is not a word" character class on either end. r"\WMY_TABLE\W" r"\WYOUR_TABLE\W" -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: HTML Parser

2013-07-02 Thread Neil Cerutti
eautifulSoup, etc. > HTMLParser works fine for me, but I am looking for a good > tutorial to learn it nicely. Take a read of the topic "Parsing, creating, and Manipulating HTML Documents" from chapter five of Text Processing in Python. http://gnosis.cx/TPiP/chap5.txt -- Neil Ceru

Re: Parsing Text file

2013-07-02 Thread Neil Cerutti
maskit in this file and also > need to print Sometext above it..SOmetext location can vary as > you can see above. > > In the first instance it is 3 lines above mask it, in the > second instance it is 4 lines above it and so on.. > > Please help how to do it? How can you te

Re: Parsing Text file

2013-07-02 Thread Neil Cerutti
> > if is_sometext(line): > memory = line > > if line == 'maskit': > print memory Tobiah's solution fits what little we can make of your problem. My feeling is that you've simplified your question a little too much in hopes that it would help us provide a better solution. Can you provide more context? -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: Default scope of variables

2013-07-05 Thread Neil Cerutti
c destruction. It wouldn't buy much except for namespace tidyness. for x in range(4): print(x) print(x) # Vader NOoOO!!! Python provides deterministic destruction with a different feature. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: Default scope of variables

2013-07-05 Thread Neil Cerutti
On 2013-07-05, Chris Angelico wrote: > On Fri, Jul 5, 2013 at 11:24 PM, Neil Cerutti > wrote: >> Python provides deterministic destruction with a different >> feature. > > You mean 'with'? That's not actually destruction, it just does > one of the same j

Re: analyzing time

2013-07-05 Thread Neil Cerutti
the methods you will need. To find clusters and min and max values you will likely need to put the datetime objects in a list, and use some Python builtins and list methods. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: Default scope of variables

2013-07-08 Thread Neil Cerutti
On 2013-07-07, Steven D'Aprano wrote: > On Fri, 05 Jul 2013 13:24:43 +0000, Neil Cerutti wrote: > >> for x in range(4): >>print(x) >> print(x) # Vader NOoOO!!! > > That loops do *not* introduce a new scope is a feature, not a bug. It is > *real

Re: crack a router passcode

2013-07-09 Thread Neil Cerutti
d just reset it to factory defaults and reconfigure. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: Editor Ergonomics [was: Important features for editors]

2013-07-09 Thread Neil Cerutti
That's the system I've adopted. I use the mouse lefty all day when working and righty all night when playing. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: hex dump w/ or w/out utf-8 chars

2013-07-09 Thread Neil Cerutti
ementors: thwarting hexdumping cheaters and cramming their games onto microcomputers with one blow. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: hex dump w/ or w/out utf-8 chars

2013-07-09 Thread Neil Cerutti
ine spec was never officially published either. I believe a "task force" reverse engineered it sometime in the 90's. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: crack a router passcode

2013-07-09 Thread Neil Cerutti
boxes of router's web login >> interface? > > It certainly could. It's just simple HTTP requests, which Python > handles admirably. But this request was sent by a spambot and doesn't > need a response. FRANK DREBBIN Yes... I know that. Now. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: Homework help requested (not what you think!)

2013-07-17 Thread Neil Cerutti
hains are an advanced technique you could introduce, but you'd need a huge list of names broken into syllables from somewhere. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: Homework help requested (not what you think!)

2013-07-17 Thread Neil Cerutti
On 2013-07-17, Chris Angelico wrote: > On Wed, Jul 17, 2013 at 11:20 PM, Neil Cerutti wrote: >> Markov chains are an advanced technique you could introduce, but >> you'd need a huge list of names broken into syllables from >> somewhere. > > You could use names br

Re: Python 3: dict & dict.keys()

2013-07-24 Thread Neil Cerutti
set again. Thanks to the set-like view of dict.keys it worked just like one might hope. Looking at it again "seen" might be a redundant parallel version of students.keys(). -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: import syntax

2013-07-30 Thread Neil Cerutti
1a) Does it work? 1b) Can you prove it? It's best to at least have some regression tests before you start refactoring and optimizing. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: PEP8 79 char max

2013-07-30 Thread Neil Cerutti
chess positions showed that they were powerfully accurate when shown positions from real games, but no better than the average schmoe when shown randomly positioned pieces. So if everyone basically follows PEP8 we all benefit from playing by the same game rules, as it were. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: PEP8 79 char max

2013-07-31 Thread Neil Cerutti
("status", 3141, "Status code from ISO-3.14159"), > ... > ): > do_something(name, value) > print(description) > > which does give some modest readability benefits, but at a > creation cost I personally am unwilling to pay. I'm actually OK with the creation cost, but not the maintenance cost. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: Problem with psycopg2, bytea, and memoryview

2013-07-31 Thread Neil Cerutti
otocol when the format and shape are also equal. The database must be returning chunks of binary data in a different shape or format than you are writing it. Perhaps psycopg2 is returning a chunk of ints when you have written a chunk of bytes. Check the .format and .shape members of the return va

Re: code review

2012-07-03 Thread Neil Cerutti
WS! > > Why "poor", Ralph? > > I am poor in the essence of ignorance's bliss, rich only in the > never-ending thirst for knowledge and more languages. In me there meet > a combination of antithetical elements which are at eternal war with > one another... I

Re: Batching HTTP requests with httplib (Python 2.7)

2012-09-18 Thread Neil Cerutti
; service_num_list = [num for num in range(0,5)] service_num_list = list(range(5)) -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: Decorators not worth the effort

2012-09-18 Thread Neil Cerutti
On 2012-09-14, Chris Angelico wrote: > But then again, who actually ever needs fibonacci numbers? If it should happen that your question is not facetious: http://en.wikipedia.org/wiki/Fibonacci_number#Applications -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: sum works in sequences (Python 3)

2012-09-19 Thread Neil Cerutti
is 0. The function tried to add 'r' to 0. That said: >>> sum('rtarze', '') Traceback (most recent call last): File "", line 1, in TypeError: sum() can't sum strings [use ''.join(seq) instead] -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: sum works in sequences (Python 3)

2012-09-19 Thread Neil Cerutti
x27;.join(sequence). To add floating point values with extended precision, see math.fsum(). To concatenate a series of iterables, consider using itertools.chain(). Are iterables and sequences different enough to warrant posting a bug report? -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: howto handle nested for

2012-09-28 Thread Neil Cerutti
e last one. Also, be sure to check itertools for occasionally for cool stuff like this. >>> for values in itertools.product(range(3), repeat=2): ... print(values) ... (0, 0) (0, 1) (0, 2) (1, 0) (1, 1) (1, 2) (2, 0) (2, 1) (2, 2) -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

zip_longest_by

2012-10-17 Thread Neil Cerutti
d tuple(grouper(item) for item in zip(*accum)) break yield tuple(grouper(item) for item in zip(*accum)) The interface could stand improvement. I find the grouper argument very convenient, but none of the other grouping iterators find it needful. Forcing n to be a keyword argument is unfortunate as well. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: A desperate lunge for on-topic-ness

2012-10-18 Thread Neil Cerutti
and it makes printouts easy to create. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: get each pair from a string.

2012-10-23 Thread Neil Cerutti
oices of algorithm and implentation. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: simple string format question

2012-10-25 Thread Neil Cerutti
int a fixed number of digits after the decimal point, so it won't do want Adrien wants. Adrien, you will need to do some post-processing on fixed point output to remove trailing zeroes. >>> print("{:.2f}".format(2.1).rstrip('0')) 2.1 >>> print("{:.2f}".format(2.127).rstrip('0')) 2.13 -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: bit count or bit set && Python3

2012-10-25 Thread Neil Cerutti
h arithmetic: def is_palindrom(n): s = str(n) return s = s[::-1] > Here's some timing results using Python 2.7: Excellent work. You can of course drop to C for arithmetic and likely triumph over Python strings. That's never been applicable for me, though. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: bit count or bit set && Python3

2012-10-25 Thread Neil Cerutti
On 2012-10-25, Neil Cerutti wrote: > Try defeating the following with arithmetic: > > def is_palindrom(n): >s = str(n) >return s = s[::-1] Sorry for the typos. It should've been: def is_palindrome(n): s = str(n) return s == s[::-1] -- Neil Cerutti -- ht

Re: bit count or bit set && Python3

2012-10-26 Thread Neil Cerutti
On 2012-10-25, Ian Kelly wrote: > On Thu, Oct 25, 2012 at 2:00 PM, Neil Cerutti > wrote: >> Yes indeed! Python string operations are fast enough and its >> arithmetic slow enough that I no longer assume I can beat a >> neat lexicographical solution. Try defeating the foll

Re: attaching names to subexpressions

2012-10-29 Thread Neil Cerutti
em, and two solutions. Solution 1 has downside > A, and solution 2 has downside B. If he complains about > downside A, you say, well, use solution 2. If he complains > about downside B, you say, well, use solution 1. > > What if he wants to avoid both downsides A and B? What solution > does he use then? You abandon the while loop and compose a generator. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: csv read clean up and write out to csv

2012-11-02 Thread Neil Cerutti
if tag == 'html': print rec elif tag == 'csv': writer.writerow(rec) else: raise ValueError("Unknown record type %s" % tag) -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: creating size-limited tar files

2012-11-07 Thread Neil Cerutti
ize(tar_file) >= limit: > close(tar_file) > tar_file = new_tar_file() > I have not used this module before, but what you seem to be asking about is: TarFile.gettarinfo().size But your algorithm stops after the file is already too big. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: Python questions help

2012-11-19 Thread Neil Cerutti
hat most others can't, .e.g, Chris Sawyer. But, as Louis Moyse, a great musician remarked: "Without hard work, talent means nothing." -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: 10 sec poll - please reply!

2012-11-20 Thread Neil Cerutti
rb, but since it's also a well-used noun it's perhaps not quite as good as send. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: Problems on these two questions

2012-11-20 Thread Neil Cerutti
uence of "elements" starting at "1", > using "distance" as the spacing, until you exceed "n", and you > want to produce a "sum" of all those elements... This one's sort of a trick question, depending on your definition of "trick". The most obvious implementation is pretty good. In both cases a web search and a little high-density reading provides insights and examples for the OP. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: Compare list entry from csv files

2012-11-27 Thread Neil Cerutti
little better, but difflib finds some stuff that it misses. In your case, the name is munged horribly in one of the files so you'll first have to first sort it out somehow. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: Compare list entry from csv files

2012-11-27 Thread Neil Cerutti
for rows, row in enumerate(names): ...though I would find 'rownum' or 'num' or just 'i' better than the name 'rows', which I find confusing. > name_find() > ofile = open('c:/Working/ttest.csv', "wb") > writer = csv.writer(wfile, delimiter=';') > for insert in namelist: > writer.writerow(insert) > wfile.close() -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: Textmining

2012-11-30 Thread Neil Cerutti
On 2012-11-30, subhabangal...@gmail.com wrote: > Python has one textming library, but I am failing to install it > in Windows. If any one can kindly help. More information needed. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: List problem

2012-12-03 Thread Neil Cerutti
To also index them: vbdix = [i for i, a in emumerate(l) if a[1] == 'VBD'] vbdno = len(indices) -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: Conversion of List of Tuples

2012-12-04 Thread Neil Cerutti
> There's a built-in that does "reduce(operator.add"; it's called "sum": > >>>> sum(a, ()) > (1, 2, 3, 4) I thought that sort of thing would cause a warning. Maybe it's only for lists. Here's the recipe from the itertools documentation:

Re: CSV out of range

2012-12-04 Thread Neil Cerutti
(x[4]) But do you really need to save the whole file in a list first? You could simply do: for record in csvreader: if len(record) >= 4: sku.append(record[4]) Or even: sku = [record[4] for record in csvreader if len(record) >= 4] -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: Good use for itertools.dropwhile and itertools.takewhile

2012-12-04 Thread Neil Cerutti
y way that felt shorter or more pythonic: I'm really tempted to import re, and that means takewhile and dropwhile need to stay. ;) But seriously, this is a quick implementation of my first thought. description = s.lstrip(string.ascii_uppercase + ' ') product = s[:-len(description)-1] -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: Good use for itertools.dropwhile and itertools.takewhile

2012-12-04 Thread Neil Cerutti
On 2012-12-04, Nick Mellor wrote: > Hi Neil, > > Nice! But fails if the first word of the description starts > with a capital letter. Darn edge cases. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: Good use for itertools.dropwhile and itertools.takewhile

2012-12-04 Thread Neil Cerutti
FIFTY TWO Chrysler LeBaron.") ['CAR FIFTY TWO', 'Chrysler LeBaron.'] >>> prod_desc("MR. JONESEY Saskatchewan's finest") ['MR. JONESEY', "Saskatchewan's finest"] """ i = 0 while

Re: Good use for itertools.dropwhile and itertools.takewhile

2012-12-05 Thread Neil Cerutti
ble. I'm struggling with the empty description bug right now. ;) -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: Good use for itertools.dropwhile and itertools.takewhile

2012-12-05 Thread Neil Cerutti
;NO DESCRIPTION") ['NO DESCRIPTION', ''] """ prod = '' desc = '' for k, g in itertools.groupby(s.split(), key=lambda w: any(c.islower() for c in w)): a = ' '.join(g) if k: desc = a else: prod = a return [prod, desc] This has no way to preserve odd white space which could break evil product name differences. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: Good use for itertools.dropwhile and itertools.takewhile

2012-12-05 Thread Neil Cerutti
On 2012-12-05, Ian Kelly wrote: > On Wed, Dec 5, 2012 at 7:34 AM, Neil Cerutti wrote: >> Well, shoot! Then this is a job for groupby, not takewhile. > > The problem with groupby is that you can't just limit it to two groups. > >>>> prod_desc("CAPSICUM RE

Re: why does dead code costs time?

2012-12-05 Thread Neil Cerutti
be in function loading time... > I'll check ceval.c > > However, isn't there a room for a slight optim here? (in this case, the > dead code is obvious, but it may be hidden by complex loops and > conditions) Maybe it's the difference between LOAD_CONST and LOAD_GLOBAL. We can wonder why g uses the latter. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: Good use for itertools.dropwhile and itertools.takewhile

2012-12-05 Thread Neil Cerutti
rod = [] desc = [] for k, g in itertools.groupby(s.split(), key=lambda w: any(c.islower() for c in w)): if prod or k: desc.extend(g) else: prod.extend(g) return [' '.join(prod), ' '.join(desc)] -- Neil Cerut

Re: Good use for itertools.dropwhile and itertools.takewhile

2012-12-05 Thread Neil Cerutti
eaks the latest groupby. A-ha! I did check your samples for the case of an empty product name and not find any started to think it couldn't happen. Change if prod or k: to if desc or prod or k: If this data file gets any weirder, let me know. ;) -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: Good use for itertools.dropwhile and itertools.takewhile

2012-12-06 Thread Neil Cerutti
On 2012-12-05, Vlastimil Brom wrote: > ... PARSNIP, certified organic I'm not sure on this one. > ('PARSNIP', ', certified organic') -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: Confused compare function :)

2012-12-06 Thread Neil Cerutti
f *not* creating that stupid list_of_strings. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: Confused compare function :)

2012-12-07 Thread Neil Cerutti
On 2012-12-07, Steven D'Aprano wrote: > On Thu, 06 Dec 2012 13:51:29 +0000, Neil Cerutti wrote: > >> On 2012-12-06, Steven D'Aprano >> wrote: >>> total = 0 >>> for s in list_of_strings: >>> try: >>> total += int(s) >

Re: Error .. Please Help

2012-12-13 Thread Neil Cerutti
is working correctly it looks like this: else: raise SomeException("{} can't happen!".format(the_context)) else: raise exception constructs have saved me a lot of time. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: New to python, do I need an IDE or is vim still good enough?

2013-01-02 Thread Neil Cerutti
or Vim that will allow simple reindenting and a bunch of other cool cursor movement powers I don't even use. ctags will also work, though I've never really needed it. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: New to python, do I need an IDE or is vim still good enough?

2013-01-02 Thread Neil Cerutti
lt indespensable. But even though I can do the same with Python, it doesn't feel crucial when writing Python. The errors are more few. ;) -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: Python is awesome (Project Euler)

2013-01-02 Thread Neil Cerutti
are checked. Working to make a solution that's complete and extensible yields the most educational benefits, I think. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: RE Help splitting CVS data

2013-01-21 Thread Neil Cerutti
ttp://www.diveintopython.net/ -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: The best, friendly and easy use Python Editor.

2013-01-24 Thread Neil Cerutti
On 2013-01-24, John Gordon wrote: > In Sharwan Joram > writes: > >> use vim. > > He said he wanted autocomplete. Does Vim have that? Yes, you use its ctags support to get it working, I believe. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: The best, friendly and easy use Python Editor.

2013-01-24 Thread Neil Cerutti
> know Python. I agree. Vim is great, Emacs is great. I'm glad I know one of them. But learning one of them is as project unto itself. So selecting either just for Python is skipping too many decisions and maybe biting off too big a piece of the snake. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: using split for a string : error

2013-01-25 Thread Neil Cerutti
know what the situations are where you want > the behaviour of atoi(). Right. atoi is no good even in C. You get much better control using the sprintf family. int would need to return a tuple of the number it found plus the number of characters consumed to be more useful for parsing. >>>

Re: using split for a string : error

2013-01-25 Thread Neil Cerutti
On 2013-01-25, Hans Mulder wrote: >> Right. atoi is no good even in C. You get much better control >> using the sprintf family. > > I think you meant sscanf. Yes, thanks for knocking that huge chunk of rust off of me. ;) -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

  1   2   3   4   5   6   7   8   9   10   >