Re: Decorator to inject function into __call__ of a class

2010-03-13 Thread Jon Clements
On 13 Mar, 16:26, Patrick Maupin wrote: > On Mar 13, 10:19 am, Jon Clements wrote: > > > What I'd like to achieve is something similar to: > > > @inject(B): > >  def some_function(a, b): > >      pass # something useful > > So, just typing at the keybo

Re: Decorator to inject function into __call__ of a class

2010-03-13 Thread Jon Clements
On 13 Mar, 16:42, Jack Diederich wrote: > On Sat, Mar 13, 2010 at 11:19 AM, Jon Clements wrote: > > This is semi-experimental and I'd appreciate opinions of whether it's > > the correct design approach or not. It seems like a good idea, but it > > doesn't

Re: Decorator to inject function into __call__ of a class

2010-03-13 Thread Jon Clements
On 13 Mar, 17:42, Jack Diederich wrote: > On Sat, Mar 13, 2010 at 12:10 PM, Jon Clements wrote: > > On 13 Mar, 16:42, Jack Diederich wrote: > >> On Sat, Mar 13, 2010 at 11:19 AM, Jon Clements > >> wrote: > >> > This is semi-experimental and I'd ap

Re: Clearing memory (namespace) before running code

2010-03-21 Thread Jon Clements
th the -n option. However I would have thought the 'tester' would be running from a terminal/command line/double click jobby, so that a single Python session is executed and just runs -- rather than want to use it interactively afterwards. hth Jon. -- http://mail.python.org/mailman/listinfo/python-list

Re: Advice needed on parallel processing in python

2010-03-24 Thread Jon Clements
hear > > Many Thanks, > Yoav Glazner Would Celery suit? http://celeryproject.org/ hth Jon. -- http://mail.python.org/mailman/listinfo/python-list

Re: Python database of plain text editable by notepad or vi

2010-03-25 Thread Jon Clements
ort without maintenance), then is a complete sequential-scan required each time, or do you just tell the user to not update when running (unless I s'pose something along the lines of a SIGHUP for config files is applicable). Sorry, just don't understand why you'd want this. Jon. -- http://mail.python.org/mailman/listinfo/python-list

Re: Python database of plain text editable by notepad or vi

2010-03-26 Thread Jon Clements
On 26 Mar, 09:49, James Harris wrote: > On 25 Mar, 22:56, Jon Clements wrote: > > > > > On 25 Mar, 22:40, James Harris wrote: > > > > I am looking to store named pieces of text in a form that can be > > > edited by a standard editor such as notepad (unde

Re: Classes as namespaces?

2010-03-26 Thread Jon Clements
loads in it, but would I create a class called algorithm (unlikely). I would tend to view modules as "namespace". Rightly or wrongly, just lets you make the right design choice. Jon. -- http://mail.python.org/mailman/listinfo/python-list

Re: OT: Meaning of "monkey"

2010-03-26 Thread Jon Clements
s derogatory. No winning when you have language that can mean "bad" (in meaning "wicked/very good/awesome" (and even 'wicked' means good sometimes - as in enthusiasm for an idea)) or actually "bad/not good [add your own synonyms]". All valid, but which is good/bad :) Anyway, this' a group for Python, not English :) Feel better for my rant :) Jon. -- http://mail.python.org/mailman/listinfo/python-list

Re: Q: We have *args and **kwargs. Woud ***allargs be useful?

2010-04-01 Thread Jon Clements
posargs]) @AllArgs def test(): print Args @AllArgs def test2(a, b): print a, b, Args test(1, 2, 3, 4, 5, a=3, b=5) test2(1, 2, 3, 4, 5, c=7) Done quickly, probably buggy, but does provide 'Args', but without further work swallows any *'s and **'s and might ignore defaults (hideously untested) hth Jon. -- http://mail.python.org/mailman/listinfo/python-list

Re: Scheme as a virtual machine?

2010-11-21 Thread Jon Harrop
not one of them. If Haskell were half of the things you think it is, it would have more credible success stories. Cheers, Jon. -- http://mail.python.org/mailman/listinfo/python-list

Re: Parsing markup.

2010-11-26 Thread Jon Clements
works fine for me - have you tried: from lxml import html text = "This is a paragraph with bold and italic elements in itIt can be made up of multiple lines separated by pagagraph tags." tree = html.fromstring(text) print tree.findall('p') # should print [, ] hth Jon -- http://mail.python.org/mailman/listinfo/python-list

Re: Login using usrllib2

2010-12-01 Thread Jon Clements
use urllib2.HTTPBasicAuthHandler or > urllib2.HTTPDigestAuthHandler. > > Cheers, > Chris > --http://blog.rebertia.com If the OP is doing this a lot I would suggest installing FF's Firebug extension. Then use the Net tab to monitor activity. Also the OP might want to look at the urllib2.HTTPSHandler. Jon -- http://mail.python.org/mailman/listinfo/python-list

Re: Packages at Python.org

2010-12-01 Thread Jon Clements
; a link > > to Sourceforge. > > Thanks to very quick replies with pointers to > > http://pypi.python.org/pypi/dbf/ > > instead of to packages.python.org/dbf [snip] > > Kirby I've only had a quick play with it, however, you may want to take a look at Dabo on http://dabodev.com/ Jon. -- http://mail.python.org/mailman/listinfo/python-list

Re: Packages at Python.org

2010-12-01 Thread Jon Clements
ork with compact index files. > > Does anybody know where I might find those? > > ~Ethan~  (author of said package) I think John Machin has done work on this, or at least mentioned it in a post somewhere. I could be wrong though - apologies to both you and John, if I'm imagining things. Jon. -- http://mail.python.org/mailman/listinfo/python-list

Re: Case Sensitive Section names configparser

2010-12-08 Thread Jon Clements
parser.html#ConfigParser.RawConfigParser That way your values would remain cased correctly, but lookups would be insensitive. hth Jon. -- http://mail.python.org/mailman/listinfo/python-list

Re: Google AI challenge: planet war. Lisp won.

2010-12-20 Thread Jon Harrop
Wasn't that the "challenge" where they wouldn't even accept solutions written in many other languages (including both OCaml and F#)? Cheers, Jon. "Xah Lee" wrote in message news:44a8f48f-e291-463e-a042-d0cbc31a2...@z17g2000prz.googlegroups.com... discovered t

Re: Modifying an existing excel spreadsheet

2010-12-21 Thread Jon Clements
s or advice? > > Thanks in advance, > >    -EdK > > Ed Keith > > e_...@yahoo.com > > Blog: edkeith.blogspot.com Have you tried: http://groups.google.com/group/python-excel and searching the archives for "template"? Similar questions have come up before there. hth Jon -- http://mail.python.org/mailman/listinfo/python-list

Re: help with link parsing?

2010-12-21 Thread Jon Clements
rt lxml from urlparse import urlsplit doc = lxml.html.parse('http://www.google.com') print map(urlsplit, doc.xpath('//a/@href')) [SplitResult(scheme='http', netloc='www.google.co.uk', path='/imghp', query='hl=en&tab=wi', fragment=''), SplitResult(scheme='http', netloc='video.google.co.uk', path='/', query='hl=en&tab=wv', fragment=''), SplitResult(scheme='http', netloc='maps.google.co.uk', path='/maps', query='hl=en&tab=wl', fragment=''), SplitResult(scheme='http', netloc='news.google.co.uk', path='/nwshp', query='hl=en&tab=wn', fragment=''), ...] Much nicer IMHO, plus the lxml.html has iterlinks() and other convenience functions for handling HTML. hth Jon. -- http://mail.python.org/mailman/listinfo/python-list

Re: Scanning directories for new files?

2010-12-21 Thread Jon Clements
similar. Although, yes, the monitoring the file system is completely possible. hth Jon. -- http://mail.python.org/mailman/listinfo/python-list

Specialisation / Interests

2010-12-21 Thread Jon Clements
seen him duck a post where re was (not) required. - the "effbot" for PIL & ElementTree - Mark Hammond for work on win32 - Mark Dickinson for floating point/number theory etc... Then so many others!... I'm leaving a huge amount out, so no rudeness intended - but what you thin

Re: help with link parsing?

2010-12-22 Thread Jon Clements
On Dec 22, 4:24 pm, "Colin J. Williams" wrote: > On 21-Dec-10 12:22 PM, Jon Clements wrote: > > > import lxml > > from urlparse import urlsplit > > > doc = lxml.html.parse('http://www.google.com') > > print map(urlsplit, doc.xpath(&

Re: Hosting a Python based TCP server

2010-12-23 Thread Jon Clements
nHosting There's quite a few and they vary in features/pricing/OS used etc... but a lot of the info and links are there for you to find one right for you. hth Jon. -- http://mail.python.org/mailman/listinfo/python-list

Re: Partition Recursive

2010-12-23 Thread Jon Clements
x27;str','.','partition'] > > The reserved char are: > > specialMeaning = ["//",";","/", "?", ":", "@", "=" , "&","#"] > > Regards > > Mario I would use urlparse.urlsplit, then split further, if required. >>> urlsplit(url) SplitResult(scheme='http', netloc='docs.python.org', path='/dev/ library/stdtypes.html', query='highlight=partition', fragment='str.partition') Jon. -- http://mail.python.org/mailman/listinfo/python-list

Re: Building sys.path at run-time?

2010-12-30 Thread Jon Clements
augh that your problem is "[a] bunch of python scripts", and another +1 'cos "I have another problem"... Damn it, if this was 10-15 years ago, with bash.org/qdb.us etc..., I'd have posted that... Thanks Roy for the laugh, Jon. -- http://mail.python.org/mailman/listinfo/python-list

Re: Career path - where next?

2011-01-12 Thread Jon Clements
ch for fund-raising, your local chinese/indian takeaway - wouldn't hurt to put their menu online with an online order form would it!? [What you might find about this, is that as they're not likely to be technical, you can take your own time, charge a reasonable amount, experiment a little and learn, and not have too tight deadlines or someone looking over your shoulder]. Brain (or somewhere else) dump finished. hth Jon. -- http://mail.python.org/mailman/listinfo/python-list

Re: Developing a program to make a family tree.

2011-01-14 Thread Jon Clements
storage back-end, a GUI (wxWindows/GTK/Qt4 etc...), how to handle GEDCOM format (unless it's not going to be compatible with other software), does it need to produce web pages/reports (and in what formats). I strongly suggest looking at GRAMPS and see what you're setting yourself up for

Re: statement level resumable exception

2011-01-21 Thread Jon Clements
quot;""[ > >     [OPCODE, [arguments, blah]], > >     ... > > """ > > > ... > > > prgN = """...""" > > > for prg in prg1, prg2, ..., prgN: > >     try: > >         prg = eval(prg) > &

Re: how to tell if cursor is sqlite.Cursor or psycopg2.Cursor

2011-01-24 Thread Jon Clements
and I can't help thinking there has to be another way to find out what > kind of thing self._curs is. Is there a better way? > > TIA > Dima I'm not 100% sure but maybe look at SQLAlchemy (or other Python ORMs) as a wrapper. That *might* abstract the "last ID" across different DB's. And still enable direct SQL querying. Jon. -- http://mail.python.org/mailman/listinfo/python-list

Re: Converting getCSS Count Code from java to python

2011-02-02 Thread Jon Clements
th;"; >     return Integer.parseInt(selenium.getEval(String.format(jsScript, > aCSSLocator))); > > } > > http://www.eviltester.com/index.php/2010/03/13/a-simple-getcsscount-h... > > Thanks for the help Maybe? http://codespeak.net/lxml/dev/cssselect.html Jon. -- http://mail.python.org/mailman/listinfo/python-list

Re: Arrays/List, filters, Pytho, Ruby

2011-02-11 Thread Jon Clements
) for idx, val in enumerate(islice(seq, 1, None)): if cmpfunc(val): return idx + 1 return -1 # or raise an exception? Off top of head, so needs work, but is fairly generic. Jon. -- http://mail.python.org/mailman/listinfo/python-list

Re: For loop comprehensions

2011-02-11 Thread Jon Clements
he PEP/feature > request process (PEP 1 pointed me here). What do other people think? > > --Ben Can't help with the PEP stuff, but ummm... is anything wrong with filter()? For some things, I personally find it more readable in some circumstances than list/gen comps. I don't m

Re: regex help: splitting string gets weird groups

2010-04-08 Thread Jon Clements
wrong with this regex, though if > someone has a neat other way to do the above task, I'm also interested > in suggestions. I would avoid .match and use .findall (if you walk through them both together, it'll make sense what's happening with your match string). >>> s = """555tHe-rain.in#=1234""" >>> re.findall('[A-Za-z]+|[0-9]+|[-.#=]', s) ['555', 'tHe', '-', 'rain', '.', 'in', '#', '=', '1234'] hth, Jon. -- http://mail.python.org/mailman/listinfo/python-list

Re: regex help: splitting string gets weird groups

2010-04-08 Thread Jon Clements
uot;"555tHe-rain.in#=1234""" unique_group = count() lookup = dict( chain( izip(string.ascii_letters, repeat('L')), izip(string.digits, repeat('D')), izip(string.punctuation, unique_group) ) ) parse = dict(D=int, L=str.capitalize) print [ parse.get(key, lambda L: L)(''.join(items)) for key, items in groupby(s, lambda L: lookup[L]) ] [555, 'The', '-', 'Rain', '.', 'In', '#', '=', 1234] Jon. -- http://mail.python.org/mailman/listinfo/python-list

Re: Open Source Pivot table (OLAP cube?)

2010-04-27 Thread Jon Clements
instructions in the OLAP server. Of course, for small datasets, just nested dicts-of-dicts rendered would probably do. hth, Jon. -- http://mail.python.org/mailman/listinfo/python-list

Re: Open Source Pivot table (OLAP cube?)

2010-04-27 Thread Jon Clements
the queried DB to be slightly out of sync with the main DB. So many options -- but I think this is getting OT for the python list. > > Thanks > >    Laszlo Again, my humble opinion, Jon. -- http://mail.python.org/mailman/listinfo/python-list

Re: Python compiled modules are too big in size (even after strip)

2010-04-27 Thread Jon Clements
armic's pre installed python 2.6.5. > > Am I missing something here? Do I have to re-configure or re-compile > the python again from sources? > > Regards > > Prashant Err, the common install on "karmic" is 2.6.4... IIRC (and probably not) the default was 2.6.2 o

Re: itertools: problem with nested groupby, list()

2010-05-04 Thread Jon Clements
help at all? my_list.sort( key=itemgetter('a','b','c') ) for a, a_iter in groupby(my_list, itemgetter('a')): print 'New A', a for b, b_iter in groupby(a_iter, itemgetter('b')): print '\t', 'New B', b for c, c_iter in groupby(b_iter, itemgetter('c')): print '\t'*2, 'New C', c for c_data in c_iter: print '\t'*3, a, b, c, c_data print '\t'*2, 'End C', c print '\t', 'End B', b print 'End A', a Jon. -- http://mail.python.org/mailman/listinfo/python-list

Re: itertools: problem with nested groupby, list()

2010-05-04 Thread Jon Clements
my_list.sort( key=itemgetter('a','b','c') ) > for a, a_iter in groupby(my_list, itemgetter('a')): >    print 'New A', a >    inner_list =  list( groupby(a_iter, itemgetter('b')) ) >    for pass in ['first pass', 'se

Re: ConfigParser.get() defaults?

2010-05-07 Thread Jon Clements
> > -tkc Not convinced about this, but a quick "work-around" would be something like: def get_config(config, section, option, ctype=str, default=None): if default is None: ret = config.get(section, option) else: confdict = config.__dict__.get('_sections

Re: shortcut for large amount of global var declarations?

2010-05-08 Thread Jon Clements
mehg...@gmail.com;http://www.facebook.com/mehgcap About 15 that *need* to be global; smells bad to me. However, you can amend a function's .func_globals attribute. Just wouldn't be going there myself. Why do you have this many? What's your use case? Jon. -- http://mail.python.org/mailman/listinfo/python-list

Re: shortcut for large amount of global var declarations?

2010-05-08 Thread Jon Clements
On 8 May, 16:03, Alex Hall wrote: > On 5/8/10, Jon Clements wrote: > > > On 8 May, 15:08, Alex Hall wrote: > >> Hi all, > >> I am sorry if this is the second message about this you get; I typed > >> this and hit send (on gmail website) but I got a

Re: Regular expression

2010-05-18 Thread Jon Clements
ng but the first one. > > > > How I can use re for this case? > > > > The string size will vary. > > > > TIA > > > Maybe the easy way is something like this: > > > m = re.match('(0x)(.*)','0x340x5A0x9B0xBA') > > m.groups

Re: Omit the headers from XML message

2010-05-28 Thread Jon Clements
On 28 May, 16:24, "kak...@gmail.com" wrote: > Hi i have the following xml message i want to omit the headers, any > hints? > > POST /test/pcp/Listener HTTP/1.1 > User-Agent: Jakarta Commons-HttpClient/3.1 > Host: 127.0.0.1:50002 > Content-Length: 547 > > http://demo.com/demo";> >   >     >      

Re: TypeError: list indices must be integers

2010-06-01 Thread Jon Clements
uced example >  >>> [[1,2,3] # forgot comma >       [4,5,6]] > Traceback (most recent call last): >    File "", line 2, in >      [4,5,6]] > TypeError: list indices must be integers, not tuple > > Terry Jan Reedy Umm... +1 for poetic effort? Jon. -- http://mail.python.org/mailman/listinfo/python-list

Re: regarding the dimensions in gui

2010-06-10 Thread Jon Clements
On 10 June, 10:40, Jean-Michel Pichavant wrote: > Chris Rebert wrote: > > On Thu, Jun 10, 2010 at 1:27 AM, Andreas Waldenburger > > wrote: > > >> On Thu, 10 Jun 2010 08:37:21 +0100 Simon Brunning > >> wrote: > > >>> On 10 June 2010 08:19, Shashwat Anand > >>> wrote: > > And please stop usi

Re: The inverse of .join

2010-06-18 Thread Jon Clements
ondered if something smoother was available. > > -- > Neil Cerutti In terms of behaviour and 'safety', I'd go for: >>> rec = { 'code1': '1,2,3', 'code2': '' } >>> next(csv.reader([rec['code1']])) ['1', '2', '3'] >>> next(csv.reader([rec['code2']])) [] hth Jon. -- http://mail.python.org/mailman/listinfo/python-list

Re: catching my own exception

2010-06-18 Thread Jon Clements
On 18 June, 18:08, nick wrote: > I have a problem with catching my own exception. Here is the > code:http://fly.srk.fer.hr/~nick/travapi/blame.php?repname=Travian+API&pat... > > Line 252 calls a method, which on line 207 raises a > SomethingBeingBuiltError exception. On line 253 I catch that > ex

Re: let optionparse.Optionparser ignore unknown command line switches.

2010-08-01 Thread Jon Clements
uld parse some of the options (but > only the one it understands) already during import. > the main program will have to parse the same options again. Take it up a level. Dedicate a module (called app_configuration) or something to do the option parsing -- everything the application ca

Re: parsing a c project

2010-08-04 Thread Jon Clements
hon ? Well using the pyparsing library, it's extremely easy to parse the C grammar. But that's not what you're asking. > > I do not have very clear which element of Python should I use > to store the struct list or class > > I would be very grateful if someone could give me some pointers. An un-intended C pun :) ? If you let the list know the use-case, then we might stand a chance of giving you some reference (C++ pun?) Jon. -- http://mail.python.org/mailman/listinfo/python-list

Re: new to python - trouble calling a function from another function

2010-08-05 Thread Jon Clements
n each floor either. A couple of things that'd be worthwhile: 1) Post the requirements for your assignment - what's it supposed to output etc... 2) Go find an elevator, take a pen and pad with you, and stand in it for 30 mins or so, and see how the real thing deals with situations and make notes. ie, does it queue requests, or decide to take the next nearest floor, when does it stop and open etc...? hth Jon. -- http://mail.python.org/mailman/listinfo/python-list

Re: new to python - trouble calling a function from another function

2010-08-06 Thread Jon Clements
On 5 Aug, 16:15, Brandon McCombs wrote: > Jon Clements wrote: > > On 5 Aug, 08:25, Brandon McCombs wrote: > >> Hello, > > >> I'm building an elevator simulator for a class assignment. I recently > >> ran into a roadblock and don't know how

Re: Using String Methods In Jump Tables

2010-08-23 Thread Jon Clements
or using it. > > +1 > > > > > The only thing that is a bit unusual is that you call it a jump table. In > > my experience, "Jump Table" is used for low-level languages where the > > table values are memory addresses. > > Yeah ... those old assem

Re: Using String Methods In Jump Tables

2010-08-23 Thread Jon Clements
On 23 Aug, 16:57, Tim Daneliuk wrote: > On 8/23/2010 10:35 AM, Jon Clements wrote: > > > > > On 20 Aug, 01:51, Tim Daneliuk wrote: > >> On 8/19/2010 7:23 PM, Steven D'Aprano wrote: > > >>> On Thu, 19 Aug 2010 18:27:11 -0500, Tim Daneliuk wrote: &

Re: multi-core software

2009-06-07 Thread Jon Harrop
o another processor, >>with very different access costs. > > Could what you are saying be summed up by saying, "The more threads > you have the more important it is to keep your threads independent, > sharing as little data as possible." I see no problem with mutable shared sta

Re: multi-core software

2009-06-07 Thread Jon Harrop
act that programmers have shown themselves, on > average, to be remarkably bad at figuring out what _should_ be done in > parallel - as opposed to what _can_ be done - and you've got a clear > indicator that threads, as we know them, are not scalable except under > a limited set of

Re: multi-core software

2009-06-07 Thread Jon Harrop
Arved Sandstrom wrote: > Jon Harrop wrote: >> I see no problem with mutable shared state. > > In which case, Jon, you're in a small minority. No. Most programmers still care about performance and performance means mutable state. -- Dr Jon D Harrop, Flying Frog C

Re: multi-core software

2009-06-07 Thread Jon Harrop
Arved Sandstrom wrote: > Jon Harrop wrote: >> Arved Sandstrom wrote: >>> Jon Harrop wrote: >>>> I see no problem with mutable shared state. >>> >>> In which case, Jon, you're in a small minority. >> >> No. Most programmers st

Re: multi-core software

2009-06-07 Thread Jon Harrop
Joshua Cranmer wrote: > Jon Harrop wrote: >> No. Most programmers still care about performance and performance means >> mutable state. > > [ Citation needed ]. > > Most programmers I've met could care less about performance. Then they have no need for parallelism

Re: multi-core software

2009-06-07 Thread Jon Harrop
Jeff M. wrote: > On Jun 7, 3:19 pm, Arved Sandstrom wrote: >> Jon Harrop wrote: >> > Arved Sandstrom wrote: >> >> Jon Harrop wrote: >> >>> I see no problem with mutable shared state. >> >> In which case, Jon, you're in a small minor

Re: multi-core software

2009-06-07 Thread Jon Harrop
Lew wrote: > As Dr. Jon pointed out upthread, one can write decent code with mutable > shared > state. It is also true that mutable state presents a lot of problems - > potential problems, ones that can be solved, but not ones that can be > solved > thoughtlessly. On the flip s

Re: multi-core software

2009-06-07 Thread Jon Harrop
ing to do with parallelism. -- Dr Jon D Harrop, Flying Frog Consultancy Ltd. http://www.ffconsultancy.com/?u -- http://mail.python.org/mailman/listinfo/python-list

Re: multi-core software

2009-06-07 Thread Jon Harrop
Lew wrote: > Jon Harrop wrote: >> I agree entirely but my statements were about parallelism and not >> concurrency. Parallel and concurrent programming have wildly different >> characteristics and solutions. I don't believe shared mutable state is >> over

Re: multi-core software

2009-06-07 Thread Jon Harrop
>> unpredictable over evolution. > > As I recall I could get exact timings on my 6502 based Commodore 64. The > issues you speak of simply weren't issues. Let's not forget Elite for the 6502 exploiting predictable performance in order to switch graphics modes partway dow

Re: multi-core software

2009-06-07 Thread Jon Harrop
Arved Sandstrom wrote: > Jon Harrop wrote: >> Arved Sandstrom wrote: >>> Lew wrote: >>>> Interesting distinction. Would it be fair to compare concurrent >>>> programming to the bricks used to build the parallel program's edifice? >>> Wa

Re: multi-core software

2009-06-07 Thread Jon Harrop
t=threadring&lang=ghc&id=3 > > shows GHC doing 50 million lightweight thread switches in 8.47 > seconds, passing a token around a thread ring. Almost all of that is > probably spent acquiring and releasing the token's lock as the token > is passed from one thread to a

Re: multi-core software

2009-06-07 Thread Jon Harrop
then, like memory latency or refresh >> time. > > Well, as Gilbert and Sullivan wrote: > - What, never? > - No, never! > - What, "Never"? > - Well, hardly ever. > Look up the LGP-30. It was quite predictable. It has been a while. Sam

Re: multi-core software

2009-06-09 Thread Jon Harrop
toby wrote: > On Jun 7, 2:41 pm, Jon Harrop wrote: >> Arved Sandstrom wrote: >> > Jon Harrop wrote: >> >> I see no problem with mutable shared state. >> >> > In which case, Jon, you're in a small minority. >> >> No. Most programmers st

Re: multi-core software

2009-06-10 Thread Jon Harrop
Arved Sandstrom wrote: > Jon Harrop wrote: >> Arved Sandstrom wrote: >>> Jon Harrop wrote: >>>> No. Concurrent programming is about interleaving computations in order >>>> to reduce latency. Nothing to do with parallelism. >>> >>> Jon

Re: multi-core software

2009-06-11 Thread Jon Harrop
Matthias Blume wrote: > "Jeff M." writes: >> But, assuming that your program works and does what it's supposed to, >> I agree with Jon that performance needs to be right near the top of >> the list of concerns. Why? Performance isn't about looking good a

Re: sqlite3, OperationalError: no such column, shouldn't that ne a ProgrammingError?

2009-06-16 Thread Jon Clements
Python versions etc... Or perhaps there's some chosen rationale... or, perhaps, for an embedded engine, no one cares how it failed, it just did... Jon -- http://mail.python.org/mailman/listinfo/python-list

Re: generator expression works in shell, NameError in script

2009-06-17 Thread Jon Clements
On Jun 17, 11:19 pm, ssc wrote: > Hello, > > I am trying to generate this list of tuples: > [(0, ''), (1, 'Dr'), (2, 'Miss'), (3, 'Mr'), (4, 'Mrs'), (5, 'Ms')] > > My code works fine in the Python shell: > > >>> titles = ['Dr', 'Miss', 'Mr', 'Mrs', 'Ms',] > >>> title_choices = [(0, '')] + list((ti

Re: Paramiko Help

2009-06-24 Thread Jon Clements
On Jun 24, 10:01 pm, Frank Ruiz wrote: > Apologies.. Python newb here.. switching from perl to python.. so > please forgive if this is a dumb question. > > I am using the paramiko module and have some global variables defined. > > i.e. > > hostname = ' 10.10.10.10' > sshport = '22' > > I am then t

Re: Paramiko help - processing multiple commands

2009-06-24 Thread Jon Clements
On Jun 24, 11:22 pm, Frank Ruiz wrote: > Greetings, > > I am trying to process multiple commands using paramiko. I have > searched other threads, and I think my use case is a little different. > I am trying to login to a storage node that has a special shell, and > as such I cant execute a script

Re: Generator Expressions and CSV

2009-07-17 Thread Jon Clements
          #foundTwiceInQuery.add(row[2]) > >             else: >                 foundOnceInQuery.add(row[2]) >                 #IDremovalQ.add(row[2]) > >     currentfile+=1 > > print "Finished processing query logs and writing new files" > print "# of Query log entries removed:" , len(foundOnceInQuery) > print "Total Time Elapsed:", timeElapsed() Just a couple of ideas: 1) load the data into a sqlite3 database and use an SQL query to extract your results (has the potential of doing what you want without you coding it, plus if your requirements change, maybe somewhat more flexible) 2) Pre-sort your input files via ID, then match-merge (may add some time/space required to sort, but then the merge should be fairly quick, plus you'll have access to the entire row in the process, not just the ID) Jon. -- http://mail.python.org/mailman/listinfo/python-list

Re: Generator Expressions and CSV

2009-07-17 Thread Jon Clements
On 17 July, 23:57, Zaki wrote: > On Jul 17, 6:40 pm, Jon Clements wrote: > > > > > On 17 July, 21:08, Zaki wrote: > > > > On Jul 17, 2:49 pm, MRAB wrote: > > > > > Zaki wrote: > > > > > Hey all, > > > > > > I'

Re: time.strftime('%m-%d-%Y %H:%m:%S') to log is out of order

2009-07-21 Thread Jon Clements
On 21 July, 22:00, davidj411 wrote: > I am using a recursive function to print the time and a few other > things on each pass. ( the function calculates size of file that is > being transferred and if not 100 % copied, it waits 20 secs and checks > again). > > i would expect the time to be correct

Re: time.strftime('%m-%d-%Y %H:%m:%S') to log is out of order

2009-07-21 Thread Jon Clements
On 21 July, 22:38, Piet van Oostrum wrote: > > davidj411 (d) wrote: > >d> I am using a recursive function to print the time and a few other > >d> things on each pass. ( the function calculates size of file that is > >d> being transferred and if not 100 % copied, it waits 20 secs and checks >

Re: Regular exprssion for IRC messages

2009-07-22 Thread Jon Clements
On 22 July, 06:43, "Gabriel Genellina" wrote: > En Fri, 17 Jul 2009 13:59:47 -0300, nohics nohics   > escribió: > > > When an IRC client receive a messages, this message in in a special   > > format > > defined here: Message format in pseudo > > BNF

Re: Detect target name in descriptor __set__ method

2009-07-22 Thread Jon Clements
mes refer to the same descriptor, no two classes   > share the same descriptor instance...). But I would like to use a more   > direct/robust approach, if available. > > Any ideas? > > -- > Gabriel Genellina >>> class Test: def __setattr__(self, what, value): print what, value >>> t = Test() >>> t.foo = 'x' foo x Is that what you're after? Jon. -- http://mail.python.org/mailman/listinfo/python-list

Re: If Scheme is so good why MIT drops it?

2009-07-23 Thread Jon Harrop
nite number of cores cannot beat F# running on 2 or more (and I already have 8) because the overheads are far too high for parallelism to pay off. -- Dr Jon D Harrop, Flying Frog Consultancy Ltd. http://www.ffconsultancy.com/?u -- http://mail.python.org/mailman/listinfo/python-list

Re: If Scheme is so good why MIT drops it?

2009-07-25 Thread Jon Harrop
ACL wrote: > Lisp project: > I don't need as many people... Is there any actual evidence of that? -- Dr Jon D Harrop, Flying Frog Consultancy Ltd. http://www.ffconsultancy.com/?u -- http://mail.python.org/mailman/listinfo/python-list

Re: How to read webpage

2009-08-01 Thread Jon Clements
et an exception, so your problem must be > elsewhere. I'm hoping this adds to MRAB's reply; it is intended however for the OP. Jeeze -- been a while since I've had to deal with Sockets (directly anyway). If memory serves correctly, it's where the system can't name resolve the required address. So best guess is it's either a temporary glitch, or an issue with your routing. Jon. Jon. -- http://mail.python.org/mailman/listinfo/python-list

Re: Newbie thwarted by sys.path on Vista

2009-08-01 Thread Jon Clements
On 1 Aug, 22:58, "Michael M Mason" wrote: > I'm running Python 3.1 on Vista and I can't figure out how to add my own > directory to  sys.path. > > The docs suggest that I can either add it to the PYTHONPATH environment > variable or to the PythonPath key in the registry.  However, PYTHONPATH > doe

Re: How to write replace string for object which will be substituted? [regexp]

2009-08-05 Thread Jon Clements
print maail > > n...@mail.com > > na...@mail.com > > na...@mail.com > > Too bad, I thought that the almighty re module could do anything, but > it failed with this (or maybe re can do what i want, but only few > people knows how to force him to that?  :P). > But with help of MRAB, i choose The 3rd Point of Python's Zen - > "Simple is better than complex." > > " > > >>> mail = '\nn...@mail.com\nname1 [at] mail [dot] com\nname2 [$at$] mail > >>> [$dot$] com\n' > >>> mail > > '\nn...@mail.com\nname1 [at] mail [dot] com\nname2 [$at$] mail [$dot$] > com\n' > > >>> print mail > > n...@mail.com > name1 [at] mail [dot] com > name2 [$at$] mail [$dot$] com > > >>> maail = mail.lstrip().rstrip().replace(' ', '').replace('[dot]', > >>> '.').replace('[$dot$]', '.').replace('[at]', '@').replace('[$at$]', '@') > >>> print maail > > n...@mail.com > na...@mail.com > na...@mail.com > > >>> #Did it  :) > > " > > Thanks again   :) Short of writing a dedicated function I might be tempted to write this as: EMAIL_REPLACEMENTS = ( ('[at]', '@'), ('[dot]', '.'), ... ) for src, dest in EMAIL_REPLACEMENTS: mail = mail.replace(src, dest) Apart from taste reasons, it keeps the replaces more obvious (and accessible via a variable rather than embedded in the code), enables swapping the order or adding/removing easier. Jon -- http://mail.python.org/mailman/listinfo/python-list

Re: Do anyone here use Python *embedded* in a database?

2009-08-05 Thread Jon Clements
thonu within postgres without too many problems. Although I do recall once that using the CSV module to load and filter external data, did consume a massive amount of memory. Even though the entire procedure was iterator based -- never did work out if it was postgres caching, or some other weird

Re: Parsing Binary Structures; Is there a better way / What is your way?

2009-08-05 Thread Jon Clements
use, but it's been about 3 years since I had to look at it. I think it used the C equiv. of short ints to do its work. Otherwise, maybe the array module, the struct module or even possibly ctypes. Not much use, but might give a few pointers. Jon. -- http://mail.python.org/mailman/listinfo/python-list

Re: Parsing Binary Structures; Is there a better way / What is your way?

2009-08-05 Thread Jon Clements
you're after, and I'm fairly curious to see what I wrote... mind you, not too hard to write again now that's jogged my memory! (although after a couple at the pub, not going to do it tonight!) Cheers, Jon. -- http://mail.python.org/mailman/listinfo/python-list

Re: Google sitemap generator in python gone?

2009-08-05 Thread Jon Clements
On 5 Aug, 22:44, Xah Lee wrote: > google used to have a sitemap generator written in python, at: >  https://www.google.com/webmasters/tools/docs/en/sitemap-generator.html > > but the url is gone. It seems the current version is moved > here:http://code.google.com/p/googlesitemapgenerator/ > and i

Re: pylucene installation problem on Ubuntu 9.04

2009-08-06 Thread Jon Clements
the whole thing running? I'll > very much thankful to you guys. > > Thanks, > KK. If you installed using apt, have you a pylucene directory under /usr/ local/lib/python2.6/dist-packages/? Also, if you run python, and import sys; print sys.path whats it show? Jon. -- http://mail.python.org/mailman/listinfo/python-list

Re: Problem with join in__str__() in class (newbie)

2009-08-09 Thread jon rascal
> def __str__(self): >      output = '%s:%s' % (self.expert_id, self.name) >      output += '\nKnown topics: %s' % (', '.join(str(self.topics))) You're turning your list into a string -- try this: ', '.join([str(x) for x in self.topics]) -- http://mail.python.org/mailman/listinfo/python-list

Re: Xah's Edu Corner: The importance of syntax & notations.

2009-08-16 Thread Jon Harrop
w_a_x_man wrote: > On Aug 16, 11:05 am, Petey Keller wrote: >> Compiler go through *great* pains > > Compiler work real hard. > Compiler have heap big trouble. ROTFL. :-) -- Dr Jon D Harrop, Flying Frog Consultancy Ltd. http://www.ffconsultancy.com/?u -- http://mail.

Re: Social problems of Python doc [was Re: Python docs disappointing]

2009-08-17 Thread Jon Harrop
anguages where user-defined functions are very slow, like Python and Mathematica? -- Dr Jon D Harrop, Flying Frog Consultancy Ltd. http://www.ffconsultancy.com/?u -- http://mail.python.org/mailman/listinfo/python-list

subclassing Scientific.IO.NetCDFFile

2009-09-06 Thread Jon Beezley
on is: Is there a simple method of containing NetCDFFile in a class? If not, how can I design a class that will behave like NetCDFFile from the user perspective? Thanks, Jon -- http://mail.python.org/mailman/listinfo/python-list

Re: Math Notations, Computer Languages, and the “Form” in Formalism

2009-09-09 Thread Jon Harrop
fortunatus wrote: > to that end you might be interested in Fortress at Sun: > > http://projectfortress.sun.com/Projects/Community > http://research.sun.com/projects/plrg/fortress.pdf > http://research.sun.com/spotlight/2007/2007-01-10_fortress.html Fortress is dead, right? --

Re: Array of objects lost in unpickling

2009-09-13 Thread Jon Clements
ere are no errors printed out. > > Any idea why the array of instances are lost? > > Thanks, > > Bahadir You most likely want 'array' to be an instance level and not class level attribute. class first(object): def __init__(self): self.array = [] myfirst = first() myfirst.array.append(23423) etc... hth, Jon. -- http://mail.python.org/mailman/listinfo/python-list

Re: List comprehension vs generator expression memory allocation

2009-09-20 Thread Jon Clements
or > the whole target list range(a,b)[m-a%m:b:m]? Yes - range always creates a list (in the 2.x series) -- mult1 creates a list, then returns a generator, so list(mult1(a,b,m)) is identical to mult2(a,b,m). Jon. -- http://mail.python.org/mailman/listinfo/python-list

Re: Evaluate coding and style

2009-09-24 Thread Jon Clements
ath.isdir(tokens[5]): print 'Directory %s not found' % tokens[5] else: print 'User %s successful' % tokens[0] > checkDir(userlist) It's fairly traditional to wrap the 'main' function inside a block to check if this script is the main one that's executing as such: if __name__ == '__main__': checkdir(userlist) This enables the program to be used in an import so that other programs can use its functions, but will only execute the check function, if it's the sole script. hth a bit, Jon -- http://mail.python.org/mailman/listinfo/python-list

Re: urllib, can't seem to get form post right

2009-09-24 Thread Jon Clements
ws NT)' > headers = { 'User-Agent' : user_agent } > > data = urllib.urlencode(values) > req = urllib2.Request(url, data, headers) > response = urllib2.urlopen(req) > the_page = response.read() > print the_page Hint: January February March Ap

Re: Format string with single quotes in it

2009-09-25 Thread Jon Clements
if not, do so... and if your file has mixed newline sequences, try using the universal newline option: infile = open ('filename','rU'). > I also tried: > > # Replace single quotes with \' > str = str.replace("'", "\'") > > an

<    4   5   6   7   8   9   10   11   12   13   >