Re: First attempt at a Python prog (Chess)

2013-02-19 Thread Neil Cerutti
On 2013-02-15, MRAB wrote: > On 2013-02-15 16:17, Neil Cerutti wrote: >> 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. > > Only

Re: Python 3.3 vs. MSDOS Basic

2013-02-20 Thread Neil Cerutti
larly good example of a Project Euler problem, you'll need to do some mathematical analysis to improve your approach, first. But yeah, do not get in the habit of comparing your times to, say, C++ programs. ;) -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: FYI: AI-programmer

2013-02-22 Thread Neil Cerutti
ull poems written > by computers. Fooled a lot of people. The painting elephants are trained to paint basically the same painting over and over. There's not much chance involved. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: Small program ideas

2013-02-26 Thread Neil Cerutti
hallenge. http://www.pythonchallenge.com/ -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: Speeding up Python's exit

2013-02-28 Thread Neil Cerutti
Disabling gc before exiting might do the trick, assuming you're assiduously managing other resources with context managers. gc.disable() exit() -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: Read csv file and create a new file

2013-02-28 Thread Neil Cerutti
: > > > mtgoxeur 12 24 36 > mtgoxpln 2 4 6 > > Thanks to anyone that can help You don't appear to need the csv module at all. You'll just need the startswith string function. For more help, please show us some code. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: Read csv file and create a new file

2013-02-28 Thread Neil Cerutti
d["ask"] is not None: > if not any(str(d["symbol"]) in s for s in string): Why are you checking d["symbol"] instead of d["currency"]? Maybe I misunderstood the question. Test like this for either set or list container type. Use whichever json field is appropriate: if d["currency"] not in esclusioni: > c.writerow([str(d["currency"]),str(d["symbol"]),str(d > ["bid"]),str(d["ask"]),str(d["currency_volume"])]) > > esclusioni.close() -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: Recursive function

2013-03-05 Thread Neil Cerutti
reverse after reverse1 is exactly the same. I can now write my recursive reverse function. def reverse_any(s): if len(s) <= 1: return s else: return s[-1] + reverse_any(s[:-1]) Try this exercise with your conversion problem and see if you can make progress. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: Config & ConfigParser

2013-03-07 Thread Neil Cerutti
Config: host = "ftp" port = 21 proxy = "192.168.0.3:81" user = "transfers" password = "secret" How much to engineer stuff is up to you. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: itertools.filterfalse - what is it good for

2013-03-08 Thread Neil Cerutti
iciency only. It can trivially be replaced by filter in all cases (at least in Python 3), but it saves you from a possibly slow extra function indirection, and also from needing to define one at all. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: crypto program in python.

2013-03-08 Thread Neil Cerutti
) > print decode(coded) > elif response == "0": > print "Thanks for doing secret spy stuff with me." > keepGoing = False > else: > print "I don't know what you want to do..." > > --- > > I am

Re: crypto program in python.

2013-03-08 Thread Neil Cerutti
an example of something you tried that didn't work? -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: Excel column 256 limit

2013-03-19 Thread Neil Cerutti
el use the csv module and create the file using the default 'excel-csv' format. Then load the file using Excel. Creating an Excel file directly in Python is possible, but I think it will require use of the Pywin32 extensions. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: What am I doing wrong in this simple tkinter example?

2013-03-19 Thread Neil Cerutti
basis... more frequently > if you use Microsoft Windows, tar, non-eight-bit-clean > transmission methods, or Adobe products, and extremely common > as soon as you take over someone else's code [1], but > inevitable even without these stimuli. :) A pretty funny example of this is

Re: How to send data from excel to website using python please help?

2013-03-19 Thread Neil Cerutti
d from them directly using something like xlrd if you prefer, but I find it pales in comparison. My advice is to avoid reading the Excel file directly unless you have no other choice. Happily (for me) I don't know the answer to the second part of your question. -- Neil Cerutti -- http://mail.py

Re: Replace "dash" values in a field with new line- VB equivalent of Python

2013-03-19 Thread Neil Cerutti
trings in Python, so you need to bind something to them. I don't know what the VB syntax above means, but if I pretend that your string is bound to 'Name': Name = Name.replace(" - ", "\n") -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: Excel column 256 limit

2013-03-20 Thread Neil Cerutti
On 2013-03-19, Ian Kelly wrote: > On Tue, Mar 19, 2013 at 8:44 AM, Tim Chase > wrote: >> On 2013-03-19 14:07, Neil Cerutti wrote: >>> On 2013-03-18, Ana Dion?sio wrote: >>> > But I still get the error and I use Excel 2010. >>> > >>> >

Re: Help me pick an API design (OO vs functional)

2013-03-26 Thread Neil Cerutti
None, your usual assumptions about focus would apply, otherwise the user preference overrides it. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: Help me pick an API design (OO vs functional)

2013-03-26 Thread Neil Cerutti
On 2013-03-26, Dave Angel wrote: > On 03/26/2013 10:40 AM, Michael Herrmann wrote: >> On Tuesday, March 26, 2013 3:13:30 PM UTC+1, Neil Cerutti wrote: >>> >>> >>> Have you considered adding a keyword argument to each of your >>> global functions,

Re: Doing both regex match and assignment within a If loop?

2013-03-29 Thread Neil Cerutti
mentioned is to match using a generator function: def match_each(s, re_seq): for r in re_seq: yield r.match(s) And later something like: for match in match_each(s, (expression1, expression2, expression3)): if match: print(match.groups()) # etc... -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: Small program ideas

2013-03-29 Thread Neil Cerutti
e final program in small steps. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: No errors displayed but i blank scren nstead.

2013-03-29 Thread Neil Cerutti
e killfiled already. Must be he/she/it is posting from a different sock puppet. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: Creating a dictionary from a .txt file

2013-04-01 Thread Neil Cerutti
His name, in combination with a similarly named rap artist, breaks most search tools. My guess is this homework is simply borken. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: Creating a dictionary from a .txt file

2013-04-03 Thread Neil Cerutti
On 2013-04-01, Steven D'Aprano wrote: > On Mon, 01 Apr 2013 11:41:03 +0000, Neil Cerutti wrote: > > >> I tried searching for Frost*, an interesting artist I recently learned >> about. > > "Interesting artist" -- is that another term for "wanker&quo

Re: Mixin way?

2013-04-03 Thread Neil Cerutti
e attribute > DEFAULTS = {} > REQUIRED = [] > OPTIONAL = [] > TO_RESOLVE = [] > MIXINS = [] > > Where every subclass can redefine these attributes to get > something done automatically by the constructor for > convenience. Hopefully someone with experience with them can help you further, but this seems like a job for a metaclass. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: Distributing a Python program hell

2013-04-03 Thread Neil Cerutti
program.) > > Run: python baudotrss.py --help > > I'm thinking of switching to Go. Python programs can be distributed as binary-like packages, e.g., www.py2exe.org. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: In defence of 80-char lines

2013-04-04 Thread Neil Cerutti
x27;server_name'), get_backend), (('Tq', 'Tw', 'Tc', 'Tr', 'Tt'), get_track_info), ] result = {} for i, s in enumerate(s.split()): if i < len(matchers): # I'm not finished writing matchers yet. key, matcher =

Re: I hate you all

2013-04-06 Thread Neil Cerutti
e Stroustrup likes it, and I agree with him that code is even easier to read that way, especially in hard-copy. But most tools have not caught up with the idea. I'll switch as soon as vim supports it. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: I hate you all

2013-04-06 Thread Neil Cerutti
On 2013-04-06, Roy Smith wrote: > In article , > Neil Cerutti wrote: > >> Bjarne Stroustrup likes it > > This is supposed to impress me? Hehe. No! But he's got enough clout to give the notion some traction. > Yeah, most of the books I recall that used this wer

Re: Can I iterate over a dictionary outside a function ?

2013-04-11 Thread Neil Cerutti
;> returned so cannot be iterated upon. >> >> Please suggest some way by which it can be made possible to >> iterate over the dictionary using iterkeys outside the >> function ? > > If you're using Python 3 iterkeys has been renamed keys. Also, using a dict

Re: guessthenumber print games left

2013-04-11 Thread Neil Cerutti
still true. Here's and example. maximum_games = 4 # You must stop playing after 4 games. games_played = 0 # Always equals the number of games played while games_played < maximum_games: play_game() # This is where you update games_played to reflect the number # of games played.

Re: shutil.copyfile is incomplete (truncated)

2013-04-11 Thread Neil Cerutti
info:"+loc+fname+":\n", os.stat(loc+fname) > > But when I look at the file in Finder, destination is smaller > and even looking at the file (with text editor) file is > truncated. > > What could be causing this? Could fn be getting some changes written after the copy is made? Is the file flushed/closed before you copy it? -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: shutil.copyfile is incomplete (truncated)

2013-04-11 Thread Neil Cerutti
urn until that's done. What command are you using to create the temp file? -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: im.py: a python communications tool

2013-04-12 Thread Neil Cerutti
matters, not > to make lawyers wealthy). Wishful thinking is the wrong way to approach any legal matter. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: classes and sub classes?

2013-04-15 Thread Neil Cerutti
ld others use? > > inventory_db > > The rest should be clear from the context. How long and descriptive a name is ought to depend on the wideness of its visibility. n might be acceptable in a short comprehension, while network_inventory_db_connection might be apposite for a module-level name. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: Newbie questions on Python

2013-04-16 Thread Neil Cerutti
he following for loop taking place somewhere: for (int i = 2; i <= 0; --i) { fprintf(a[i]); } -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: Newbie questions on Python

2013-04-16 Thread Neil Cerutti
On 2013-04-16, Lele Gaifax wrote: > Neil Cerutti writes: > >> Imagine something like the following for loop taking place >> somewhere: >> >> for (int i = 2; i <= 0; --i) { >> fprintf(a[i]); >> } > > Neil most probably meant &

Re: anyone know pandas ? Don't understand error: NotImplementedError...

2013-04-18 Thread Neil Cerutti
should be using one of its subclasses instead, e.g., BusinessDay, MonthEnd, MonthBegin, BusinessMonthEnd, etc. http://pandas.pydata.org/pandas-docs/dev/timeseries.html -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: The type/object distinction and possible synthesis of OOP and imperative programming languages

2013-04-18 Thread Neil Cerutti
based_programming. > You can emulate an OOP system with a prototype-based language. > > I highly recommend you read a book on formal programming > language theory and concepts. Let me recommend Concepts, Techniques and Models of Computer Programming, Van Roy and Haridi. http://www.info.

Re: equivalent to C pointer

2013-04-18 Thread Neil Cerutti
ions until it actually tries to call them. At that time, if either one isn't defined properly Python will raise an exception. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: itertools.groupby

2013-04-22 Thread Neil Cerutti
while True: try: e = lst.index(header, b) except ValueError: yield lst[b:] break yield lst[b:e] b = e+1 for group in headered_groups([line.strip() for line in open('data.txt')], "Starting a new group"): print(group) -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: There must be a better way

2013-04-22 Thread Neil Cerutti
ere is a rationale for the change from csv.reader.next > to csv.reader.__next__. > > If next is not acceptable for the version 3 csv.reader, perhaps __next__ > could be added to the version 2 csv.reader, so that the same code can be > used in the two versions. > > This would avoid the kluge I used above. Would using csv.DictReader instead a csv.reader be an option? -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: itertools.groupby

2013-04-22 Thread Neil Cerutti
On 2013-04-22, Oscar Benjamin wrote: > On 22 April 2013 15:24, Neil Cerutti wrote: >> >> Hrmmm, hoomm. Nobody cares for slicing any more. >> >> def headered_groups(lst, header): >> b = lst.index(header) + 1 >> while True: >>

Re: There must be a better way

2013-04-23 Thread Neil Cerutti
7;DIV') for rec in reader: major = rec[majr_index] rec[div_index] = DIVISION_TABLE[major] But a csv.DictReader might still be more efficient. I never tested. This is the only place I've used this "optimization". It's fast enough. ;) -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: Weird python behavior

2013-04-24 Thread Neil Cerutti
n session. It's a mystery why even that program threw an > error. Regardless, why should that session throw an import > error in this session? Weird. Any help is appreciated. Thanks, 'Cause Python's import statement looks in the current directory first for files to import. So yo

Re: My gui

2013-04-24 Thread Neil Cerutti
nce, but it's usual to call mainloop of the root window, rather than tkinter.mainloop. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: Finding the source of an exception in a python multiprocessing program

2013-04-24 Thread Neil Cerutti
crash your program. This is hiding the actual context. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: Finding the source of an exception in a python multiprocessing program

2013-04-25 Thread Neil Cerutti
On 2013-04-24, William Ray Wing wrote: > On Apr 24, 2013, at 4:31 PM, Neil Cerutti wrote: > >> On 2013-04-24, William Ray Wing wrote: >>> When I look at the pool module, the error is occurring in >>> get(self, timeout=None) on the line after the final else: >

Re: Comparison Style

2013-04-25 Thread Neil Cerutti
gt; inaudible. Well I've never heard either one. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: xml.etree.ElementTree if element does not exist?

2013-04-29 Thread Neil Cerutti
www.huawei.com.cn/schema/common/v2_1}sepid";) if sepelem is not None: sepid = sepid.text else: sepid = '' The empty string works for my purposes. Your script might need something else. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: [pyxl] Re: xlrd 0.9.2 released!

2013-04-29 Thread Neil Cerutti
ade the life of a few of my coworkers incrementally easier. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: xml.etree.ElementTree if element does not exist?

2013-04-29 Thread Neil Cerutti
On 2013-04-29, Neil Cerutti wrote: > find returns None when it doesn't find what you asked for. So you > can't check the .text attribute right away unless you want an > exception thrown. I deal with these annoyances like this: > > sepelem = > content.find("./

Re: "python.exe has stopped working" when os.execl() runs on Windows 7

2013-05-02 Thread Neil Cerutti
s directed. In any case, on Windows I would normally need to do something like this instead: os.execlp('cmd.exe', 'cmd.exe', '/K', 'ping.exe') -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: First python program, syntax error in while loop

2013-05-03 Thread Neil Cerutti
my number in", tries, "tries" > else: > print "\nSorry, you took too many tries to guess my number!" > raw_input("\n\n Press any key to exit..") > > ## Maybe now I can work on a useful project Not quite yet. Players who guess correctly on the fifth try don't get credit. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: First python program, syntax error in while loop

2013-05-06 Thread Neil Cerutti
On 2013-05-03, John Gordon wrote: > In Neil Cerutti writes: > >> Not quite yet. Players who guess correctly on the fifth try don't >> get credit. > > Are you sure? tries is initialized to zero and isn't > incremented for the initial guess. while (numb

Re: Reference Variables In Python Like Those In PHP

2006-08-15 Thread Neil Cerutti
t; 2 > 2 > > Is this available in python? If you store an item in a one-element list, you can use the list like a reference, but it's not syntactically transparent. >>> x = [1] >>> y = x Now x and y refer to the same list. Now you can change the elements in th

Re: Printing n elements per line in a list

2006-08-17 Thread Neil Cerutti
shorter than length n.""" t = len(seq) for i in xrange(n, t+1, n): print isep.join(map(str, seq[i-n:i]))+rsep, t = t % n if t > 0: print isep.join(map(str, seq[-t:]))+rsep, That's probably similar to some of the other mostly non-functional solutions posted. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: Simple Python App Server

2006-08-18 Thread Neil Cerutti
s present, you can run a Python script with the :pyfile command. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: Regular Expression question

2006-08-21 Thread Neil Cerutti
self.name_attrs = attrs p = MyHTMLParser() p.feed(""" """) print repr(p.result) p.close() There's probably a better way to search for attributes in attr than "for attr in attrs", but I didn't think of it, and th

Re: istep() addition to itertool? (Was: Re: Printing n elements per line in a list)

2006-08-21 Thread Neil Cerutti
itertool? Your note me curious enough to re-read the itertools documentation, and I found the following in 5.16.3 Recipes: def grouper(n, iterable, padvalue=None): "grouper(3, 'abcdefg', 'x') --> ('a','b','c'), ('d','e','f'), ('g','x','x')" return izip(*[chain(iterable, repeat(padvalue, n-1))]*n) Wish I'd found that yesterday. ;) -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: List Splitting

2006-08-21 Thread Neil Cerutti
the list belongs together: > > Group 1 = 0, 3, 6 > Group 2 = 1, 4, 7 > Group 3 = 2, 5, 8 from itertools import islice grouped = [] grouped.append(list(islice(t, 0, None, 3)) grouped.append(list(islice(t, 1, None, 3)) grouped.append(list(islice(t, 2, None, 3)) grouped.sort() This can probably be simplified and generalized, but I'm a novice, and that's a start. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: Python and STL efficiency

2006-08-23 Thread Neil Cerutti
On 2006-08-23, Amanjit Gill <[EMAIL PROTECTED]> wrote: > you should also include for ostream_operator. , actually. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: item access time: sets v. lists

2006-10-04 Thread Neil Cerutti
ot;list ->", t2.timeit(1000) print "\nRandom access to item in list/set when item exists" t1=timeit.Timer("500 in z","z = set(xrange(1))") t2=timeit.Timer("500 in z", "z = list(xrange(1))") print "set ->", t1.timeit(1000) print "list ->", t2.timeit(1000) -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: item access time: sets v. lists

2006-10-04 Thread Neil Cerutti
On 2006-10-04, Paul McGuire <[EMAIL PROTECTED]> wrote: > "Neil Cerutti" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] > >> Look at the code again. It's not testing what it says it's >> testing. > > It isnt? >

Re: Strange sorting error message

2006-10-05 Thread Neil Cerutti
r/faqs/smart-questions.html > Or are you just being plain rude? > A lack of a response from you implies the latter... SPOILER SPACE It was a joke, based on you hiding what you are doing, he decided to hide the solution to your problem. Get it? -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: building strings from variables

2006-10-05 Thread Neil Cerutti
e_string_fmt(): > out = "cd %s ; %s %d %s %s" % ht Incidentally, changing the fmt test to be more similar to the Template version doesn't slow it down much. def make_string_fmt(): out = "cd %(working_dir)s ; %(ssh_cmd)s %(some_count)d %(some_param1)s"\ "%(some_param2)s" % hd -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: Strange sorting error message

2006-10-06 Thread Neil Cerutti
On 2006-10-06, hanumizzle <[EMAIL PROTECTED]> wrote: > On 10/5/06, Neil Cerutti <[EMAIL PROTECTED]> wrote: > >> It was a joke, based on you hiding what you are doing, he decided >> to hide the solution to your problem. Get it? > > What if it was for a proprieta

Re: n-body problem at shootout.alioth.debian.org

2006-10-06 Thread Neil Cerutti
se, perhaps that's the right way to do it in Perl. A python solution that indexed lists instead of looking up attributes of objects might be faster. -- Neil Cerutti We're not afraid of challenges. It's like we always say: If you want to go out in the rain, be prepared to

Re: Names changed to protect the guilty

2006-10-06 Thread Neil Cerutti
th soldering iron ala Chris Walken. :) I agree on both points. It's a style issue, and that hidden tests (taking advantage of how certain objects convert to boolian values) is harder to read. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: Names changed to protect the guilty

2006-10-06 Thread Neil Cerutti
n the original case, I'd agree that "if X.has_key():" is quite clear, already yielding a boolian value, and so doesn't need to be tested for if it's False. But I wouldn't like to test for an empty list or for None implicitly. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: Names changed to protect the guilty

2006-10-07 Thread Neil Cerutti
On 2006-10-07, MonkeeSage <[EMAIL PROTECTED]> wrote: > > On Oct 6, 8:34 pm, Neil Cerutti <[EMAIL PROTECTED]> wrote: >> And in the original case, I'd agree that "if X.has_key():" is >> quite clear, already yielding a boolian value, and so doesn&#x

Re: does raw_input() return unicode?

2006-10-11 Thread Neil Cerutti
m all mindboggley. Just when I thought I was starting to understand how this character encoding stuff works. Are PythonWin's stdout and stdin implementations is incomplete? -- Neil Cerutti A song fest was hell at the Methodist church Wednesday. --Church Bulletin Blooper -- http://mail.python.org/mailman/listinfo/python-list

Re: Encode differences between idle python and python

2006-10-11 Thread Neil Cerutti
''.join(chr(a) for a in range(0xc0, 0xdf)).decode('ISO 8859-1') # Print it to stdout, converting to the terminal's encoding, replacing # unprintable characters with '?'. print some_string.encode(sys.stdout.encoding, 'replace') -- Neil Cerutti That&

Re: does raw_input() return unicode?

2006-10-12 Thread Neil Cerutti
On 2006-10-11, Martin v. Löwis <[EMAIL PROTECTED]> wrote: > Neil Cerutti schrieb: >> I'm all mindboggley. Just when I thought I was starting to >> understand how this character encoding stuff works. Are >> PythonWin's stdout and stdin implementations is incom

Re: Standard Forth versus Python: a case study

2006-10-12 Thread Neil Cerutti
On 2006-10-12, Paul Rubin wrote: > Tarjan discovered a guaranteed O(n) algorithm in the 1970's(?) Huhn! I thought Tarjan was just the big bad evil guy in Bard's Tale 2 who was creating eternal winter. I'm glad he also contributed to our stock of *useful* algorithms. -- Ne

Re: Standard Forth versus Python: a case study

2006-10-12 Thread Neil Cerutti
7; right away! As far as I know, he just forgot to strip out the tab characters before pasting and posting. -- Neil Cerutti We will not have an all volunteer army. We *will* have an all volunteer army. --George W. Bush -- http://mail.python.org/mailman/listinfo/python-list

Re: paseline(my favorite simple script): does something similar exist?

2006-10-12 Thread Neil Cerutti
def parseline(line,format): > xlat = {'x':None,'s':str,'f':float,'d':int,'i':int} > result = [ xlat[f](w) for f,w in zip(format,line.split()) > if xlat.get(f,None) ] > if len(result) == 0: return None > if len

Re: Appropriate way to quit Tkinter

2006-10-13 Thread Neil Cerutti
way if I run from IDLE or from the DOS > command prompt. I had some fun trying to run Tkinter from from the Python embedded in Vim. My advice: Do not do that. -- Neil Cerutti The majority of time, it seems to be one thing or the other. --Ron Mercer -- http://mail.python.org/mailman/listinfo/python-list

Re: Best IDE?

2006-10-13 Thread Neil Cerutti
free * Totally configurable. > Disadvantages: > > * No UI builder...for this you can use Glade or maybe Boa Constructor > * Not many else...none other that I can think of right now, actually * Totally configurable. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: Best IDE?

2006-10-13 Thread Neil Cerutti
On 2006-10-13, Gerrit Holl <[EMAIL PROTECTED]> wrote: > On 2006-10-13 16:31:37 +0200, Ahmer wrote: >> Subject: Best IDE? > > cat > foo.py > >> How much does it cost? > > 0 On Windows this editor is invoked like this: COPY CON: FOO.PY HTH! HAND! --

Re: COM error

2006-10-13 Thread Neil Cerutti
eriously, the function you called expected a COM object and you passed it something else. Without seeing more code, it's hard to be any helpfuller. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: comparing Unicode and string

2006-10-16 Thread Neil Cerutti
ng an error here is unnecessary. I guess that > the comparison operator decides to convert s2 to a Unicode but > forgets that I said #coding: iso-8859-1 at the beginning of the > file. It's trying to interpret s2 as ascii, and failing, since 129 and 225 code points are out of range. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: Strange Behavior

2006-10-16 Thread Neil Cerutti
complicated calculations: I'd say the feature is "usable" rather than "useful", like bitfields in C. -- Neil Cerutti Next Sunday Mrs. Vinson will be soloist for the morning service. The pastor will then speak on "It's a Terrible Experience." --Church Bulletin Blooper -- http://mail.python.org/mailman/listinfo/python-list

Re: Alphabetical sorts

2006-10-16 Thread Neil Cerutti
Check out strxfrm in the locale module. >>> a = ["Neil", "Cerutti", "neil", "cerutti"] >>> a.sort() >>> a ['Cerutti', 'Neil', 'cerutti', 'neil'] >>> import locale >>> loca

Re: Need a strange sort method...

2006-10-16 Thread Neil Cerutti
rcus Peanuts (Turkish Delight for you non-Yanks). -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: Alphabetical sorts

2006-10-17 Thread Neil Cerutti
On 2006-10-17, Ron Adam <[EMAIL PROTECTED]> wrote: > Neil Cerutti wrote: >> On 2006-10-16, Ron Adam <[EMAIL PROTECTED]> wrote: >>> I have several applications where I want to sort lists in >>> alphabetical order. Most examples of sorting usually sort on >

Re: making a valid file name...

2006-10-17 Thread Neil Cerutti
n. Even after applying psyco find was still faster (though I could beat the bisect functions by a little bit by replacing a divide with a shift). -- Neil Cerutti This is not a book to be put down lightly. It should be thrown with great force. --Dorothy Parker -- http://mail.python.org/mailman/listinfo/python-list

Re: Faulty encoding settings

2006-10-17 Thread Neil Cerutti
On 2006-10-17, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote: > In <[EMAIL PROTECTED]>, Neil Cerutti wrote: >> I'm writing an application that needs all internal character data >> to be stored in iso-8859-1. It also must allow input and output >&g

Re: making a valid file name...

2006-10-17 Thread Neil Cerutti
re I come from, a portable filename is only 8 chars long and matches the regex [A-Z][A-Z0-9]*, i.e., capital letters and numbers, with no extension. That way it'll work on old DOS machines and on Risc-OS. Wait... is there Python for Risc-OS? -- Neil Cerutti > > HTH, cu l8r, Edgar. -- http://mail.python.org/mailman/listinfo/python-list

Re: python's OOP question

2006-10-18 Thread Neil Cerutti
ot; It's pity it didn't get called quack typing. One ckecks if some unknown noun can quack, not if a duck can do something unknown. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

codecs.EncodedFile

2006-10-18 Thread Neil Cerutti
. As it is it silently causes interactive applications to apparently hang forever, and breaks the line-buffering expectation of non-interactive applications. If raising the exception is too much to ask, then at least it should be documented better. -- Neil Cerutti The choir invites any mem

Re: codecs.EncodedFile

2006-10-18 Thread Neil Cerutti
On 2006-10-19, Leo Kislov <[EMAIL PROTECTED]> wrote: > Neil Cerutti wrote: >> It turns out to be troublesome for my case because the >> EncodedFile object translates calls to readline into calls to >> read. >> >> I believe it ought to raise a NotImplement

Re: making a valid file name...

2006-10-18 Thread Neil Cerutti
k()-t, 2) > > t = clock() > sgood = set(good) > for c in data: > c in sgood > print round(clock()-t, 2), "\n" > > main() On my Python2.4 for Windows, they are often still neck-and-neck for len(good) = 26. set's disadvantage of having to be constructed is heavily amortized over 100,000 membership tests. Without knowing the usage pattern, it'd be hard to choose between them. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: UTF-8 to unicode or latin-1 (and yes, I read the FAQ)

2006-10-19 Thread Neil Cerutti
\xb6ni'.decode('utf-8') returns a Unicode > object. With print this is implicitly converted to string. The > char set used depends on your console No, the setting of the console encoding (sys.stdout.encoding) is ignored. It's a good thing, too, since it's pretty flaky. It

Re: UTF-8 to unicode or latin-1 (and yes, I read the FAQ)

2006-10-19 Thread Neil Cerutti
On 2006-10-19, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote: > In <[EMAIL PROTECTED]>, Neil Cerutti wrote: > >>> Note that 'K\xc3\xb6ni'.decode('utf-8') returns a Unicode >>> object. With print this is implicitly converted

Re: UTF-8 to unicode or latin-1 (and yes, I read the FAQ)

2006-10-19 Thread Neil Cerutti
On 2006-10-19, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote: > In <[EMAIL PROTECTED]>, Neil Cerutti wrote: >>> Note that 'K\xc3\xb6ni'.decode('utf-8') returns a Unicode >>> object. With print this is implicitly converted to strin

Re: invert or reverse a string... warning this is a rant

2006-10-19 Thread Neil Cerutti
string') > invert({1:2, 3:4}) Shoot, now you'll have to remember where in heck you stashed that function the next time you need to reverse something. ;-) You'll still be better off in the long run memorizing the slice notation. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: comparing Unicode and string

2006-10-19 Thread Neil Cerutti
characters. My current project (an implementation of the Glk API in Python) would be more troublesome to write if I had to store all my latin-1 character strings as lists or arrays of bytes. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: invert or reverse a string... warning this is a rant

2006-10-19 Thread Neil Cerutti
On 2006-10-19, Fredrik Lundh <[EMAIL PROTECTED]> wrote: > James Stroud wrote: > > > without requiring an iterator > > can we perhaps invent some more arbitrary constraints while > we're at it? No letter G. I don't like them. They wet their nests. --

Re: proper format for this database table

2006-10-20 Thread Neil Cerutti
t; Wrong newsgroup, then. comp.database.* is right next door... > > I know, I'm sorry. It's just that this newsgroup server doesn't > have any database ngs on it. :( Try Google Groups for these annoying cases. -- Neil Cerutti The audience is asked to remain seated until

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