Re: Deleting more than one element from a list

2010-04-21 Thread Simon Brunning
On 21 April 2010 20:56, candide wrote: > Is the del instruction able to remove _at the same_ time more than one > element from a list ? Yup: >>> z=[45,12,96,33,66,'c',20,99] >>> del z[:] >>> z [] -- Cheers, Simon B. -- http://mail.python.org/mailman/listinfo/python-list

Re: reading XML file using python

2010-05-17 Thread Simon Brunning
ElementTree in the standard library is one good choice here if you're not wedded to one of DOM or SAX. What have you tried so far? No one is going to write code for you, but we'd be happy to help you fix problems with your own code. <http://catb.org/~esr/faqs/smart-questions.html>

Re: reading XML file using python

2010-05-17 Thread Simon Brunning
On 17 May 2010 10:43:06 UTC+1, Shanti Bhushan wrote: > Hi simon, > you are right in 2nd paragaraph. > i have a piece of XML with some URLs in it that i want to > extract. > I have no clue from where to get help on this. > Please atleast guide me for document or link where i can

Re: Is this an ok thing to do in a class

2010-05-18 Thread Simon Brunning
On 18 May 2010 06:21:32 UTC+1, Vincent Davis wrote: > > Just wondering if there is a problem with mixing a dictionary into a class > like this. Everything seems to work as I would expect. No problem at all AFAIC. -- Cheers, Simon B. -- http://mail.python.org/mailman/listinfo/python-list

Re: Reading data from a Microsoft Access 2003 database

2010-05-19 Thread Simon Brunning
les. mxODBC might well be what you are looking for, -- Cheers, Simon B. -- http://mail.python.org/mailman/listinfo/python-list

Re: where are the program that are written in python?

2010-05-21 Thread Simon Brunning
On 21 May 2010 11:21:11 UTC+1, Deep_Feelings wrote: > 1- where are the programs that is written in python ? > 2- python is high productivity language : why there are no commercial > programs written in python ? See http://www.python.org/about/success/ -- Cheers, Simon B.

Re: where are the program that are written in python?

2010-05-21 Thread Simon Brunning
t can't tell you what they are. ;-) -- Cheers, Simon B. -- http://mail.python.org/mailman/listinfo/python-list

Re: logging: AttributeError: 'module' object has no attribute 'getLogger'

2010-05-23 Thread Simon Brunning
ng your module something else, and you should be golden. -- Cheers, Simon B. -- http://mail.python.org/mailman/listinfo/python-list

Re: Email in 2.6.4

2010-05-24 Thread Simon Brunning
On 24 May 2010 14:59:24 UTC+1, dirknbr wrote: > It doesn't error on 'import email' but does on call to MimeText. > > import email > msg = MIMEText('test') > > NameError: name 'MIMEText' is not defined Here you want: msg = email.MIMEText(&#x

Re: Address of an immutable object

2010-05-30 Thread Simon Brunning
plementation detail, and shouldn't be relied upon. This same issue also comes up with people noticing that they can compare small integers with the 'is' operator, and getting a surprise when bigger numbers come along: >>> a = 256 >>> b = 256 >>> a is b True >>> a = 257 >>> b = 257 >>> a is b False -- Cheers, Simon B. -- http://mail.python.org/mailman/listinfo/python-list

Re: Python Forum

2010-06-02 Thread Simon Brunning
On 2 June 2010 09:04:56 UTC+1, pyDev wrote: > I hope here will be > someone ready to welcome and help newcomers to enter the beautiful > world of Python. Just send them here, or to <http://mail.python.org/mailman/listinfo/tutor>. We'll be happy to help. -- Cheer

Re: GUIs - A Modest Proposal

2010-06-07 Thread Simon Hibbs
d code base by 2x or more just isn't supportable. Tkinter is perfectly adequate for basic GUIs. If you want something more sophisticated there are plently of high quality, well documented alternatives to match your platform or functionality requirements. Simon Hibbs -- http://mail.python.org/mailman/listinfo/python-list

Re: help me

2010-06-09 Thread Simon Brunning
On 9 June 2010 11:44, madhuri vio wrote: > thankyou so much ..i made it finally... > how do i make buttons and i want a lil text to label the buttons also You might want to run through <http://www.pythonware.com/library/tkinter/introduction/>. -- Cheers, Simon B. -- http://mai

Re: help me

2010-06-09 Thread Simon Brunning
module names be lower case. Python 3 was an opportunity to make non-backwardly compatible fixes, including to the standard library. -- Cheers, Simon B. -- http://mail.python.org/mailman/listinfo/python-list

Re: grep command

2010-06-10 Thread Simon Brunning
On 10 June 2010 07:38, madhuri vio wrote: > > i was wondering bout the usage and syntax of > grep command..can u tall me its syntax so that > i can use it and proceed...pls That's really not on topic for this list. -- Cheers, Simon B. -- http://mail.python.org/mailman/listinfo/python-list

Re: regarding the dimensions in gui

2010-06-10 Thread Simon Brunning
On 10 June 2010 08:19, Shashwat Anand wrote: > And please stop using 'sir' for heaven's sake. Not least because list list isn't male only. -- Cheers, Simon B. -- http://mail.python.org/mailman/listinfo/python-list

Re: a +b ?

2010-06-11 Thread Simon Brunning
2010/6/11 yanhua : > hi,all! > it's a simple question: > input two integers A and B in a line,output A+B? print sum(int(i) for i in raw_input("Please enter some integers: ").split()) -- Cheers, Simon B. -- http://mail.python.org/mailman/listinfo/python-list

Re: Python on Android Mobile?

2010-06-13 Thread Simon Brunning
me to the Android environment?  I'm not talking > backend stuff here but full front and center like full GTK or WX > development for the devices? Sadly, I gather that Google has no plans for this. But hey, it's open source, right? -- Cheers, Simon B. -- http://mail.python.org/mailman/listinfo/python-list

Re: Another MySQL Problem

2010-06-23 Thread Simon Malinge
On Wed, 23 Jun 2010 10:46:37 -0430, Victor Subervi wrote: > On Wed, Jun 23, 2010 at 10:25 AM, Stephen Hansen > wrote: > >> On 6/23/10 6:45 AM, Victor Subervi wrote: >> > Hi; >> > I have this line: >> > >> > cursor.execute('select clientEmail from clients where client=%s', >> > (string.replace(c

Re: optparse TypeError

2010-06-28 Thread Simon Brunning
m=tb,maxi=lines) Here you are attempting to call a function with the name 'lines'. But 'lines' has been assigned an integer above. I'm assuming that elsewhere you've defined a function called 'lines'. You'll need to call either the function or the option by anot

Re: Load/Performance Testing of a Web Server

2010-07-09 Thread Simon Brunning
use a > more pythonic approach. The Grinder? -- Cheers, Simon B. -- http://mail.python.org/mailman/listinfo/python-list

Is python suitable for my needs?

2010-07-15 Thread Simon SSt
to know if Python is suitable for helping me: Monitoring the UNIX box? Get some metrics from Sybase and Oracle? Get JMX metrics from Weblogic Server (Weblogic Server is provided with a scripting tool based on Jython) Thanks for your hints. Simon -- http://mail.python.org/mailman/listinfo/python-list

Re: Is python suitable for my needs?

2010-07-15 Thread Simon SSt
Le 15/07/2010 14:26, Steven D'Aprano a écrit : On Thu, 15 Jul 2010 09:36:25 +0200, Simon SSt wrote: Hi, Never too late to discover a new language :-) I hope anybody could help me answering my questions. I'm a technical consultant for a software editor. Our software is running o

Re: Mechanize - save to XML or CSV

2010-08-02 Thread Simon Brunning
or a csv > file? Sure, but mechanize only does the first half of the job. You retrieve the data using mechanize, then use another module for the save-as bit. ElementTree for XML and csv for, um, for csv are both in the standard library. -- Cheers, Simon B. -- http://mail.python.org/mailman/listinfo/python-list

Re: python interview quuestions

2010-08-13 Thread Simon Brunning
e candidate to come in and pair with one of our devs in adding a simple feature or two to their own code. It's time consuming, but not so time consuming as hiring a weak dev. -- Cheers, Simon B. -- http://mail.python.org/mailman/listinfo/python-list

Re: Programming language comparison examples?

2009-06-06 Thread Simon Brunning
tp://www.codecodex.com/wiki/index.php?title=Main_Page > http://merd.sourceforge.net/pixel/language-study/scripting-language/ > http://pleac.sourceforge.net/ > http://www.angelfire.com/tx4/cus/shapes/index.html And my favorite: http://99-bottles-of-beer.net/ -- Cheers, Simon B. -- http://mai

Re: Graphical library - charts

2009-06-22 Thread Paul Simon
I suggest you look at matplotlib. It's a bit of a learning curve but will do whatever you need. I have a similar requirement and found that gnuplot did not work for me. The plots are impressive. Paul Simon wrote in message news:h1nv4q$5k...@news.dialog.net.pl... > Hello, &g

Re: What does Guido want in a GUI toolkit for Python?

2009-06-28 Thread Simon Forman
a GUI toolkit for Python? FWIW, I created a simple GUI builder module I call pygoo that lets you create Tkinter GUIs from a simple text "specification". http://www.pygoo.com/ http://code.google.com/p/pygoo/ Warm regards, ~Simon -- http://mail.python.org/mailman/listinfo/python-list

Re: Beginning with Python; the right choice?

2009-06-28 Thread Simon Brunning
n.co.uk/politics/2009/jun/18/mps-expenses-crowdsourcing-app> - The Guardian, a UK national newspaper, quickly wrote and deployed a Python application to allow their readers to cooperate in the massive manual task of analysing MPs' expenses receipts, looking for ill-doing. -- Cheers, Simon B. -- http://mail.python.org/mailman/listinfo/python-list

Re: creating garbage collectable objects (caching objects)

2009-06-28 Thread Simon Forman
On Jun 28, 11:03 am, News123 wrote: > Hi. > > I started playing with PIL. > > I'm performing operations on multiple images and would like compromise > between speed and memory requirement. > > The fast approach would load all images upfront and create then multiple > result files. The problem is,

Re: Flexible warning system

2009-06-29 Thread Simon Forman
e warning category (see below), the text of the warning message, and the source location where it is issued. Repetitions of a particular warning for the same source location are typically suppressed." - http://docs.python.org/library/warnings.html That said, why not just use exceptions? HTH, ~Simon -- http://mail.python.org/mailman/listinfo/python-list

Re: The Python Way for module configuration?

2009-06-29 Thread Simon Forman
On Sun, Jun 28, 2009 at 1:22 PM, kj wrote: > In <87fxdlujds@benfinney.id.au> Ben Finney > writes: > >>(Even if you don't want to receive email, could you please give your >>actual name in the ‘From’ field instead of just initials? It makes >>conversation less confusing.) > > I don't know why,

Re: Good books in computer science?

2009-06-29 Thread Simon Forman
On Sat, Jun 13, 2009 at 11:49 AM, koranthala wrote: > Hi all, >    I do understand that this is not a python question and I apologize > for that straight up. >    But I am a full time follower of this group and I have seen very > very brilliant programmers and solutions. >    I also want to be a go

Re: Creating an Instance Messenger type of application

2009-06-29 Thread Simon Forman
On Mon, Jun 29, 2009 at 12:18 PM, Elf Scripter wrote: > Hello, > Has anyone created an Instance Messenger in Python before, i mean a simple > or Complex GUI based instance messenger? > I thought about something like, the client also act as server, has it`s own > listening port, but how can i handle

Re: Creating an Instance Messenger type of application

2009-06-29 Thread Simon Forman
On Mon, Jun 29, 2009 at 12:44 PM, Elf Scripter wrote: > Thank you for correcting my mistake. > I checked google but nothing close. did you have any idea? > > On Mon, Jun 29, 2009 at 5:42 PM, Simon Forman wrote: >> >> On Mon, Jun 29, 2009 at 12:18 PM, Elf Scripter >&g

problem installing python 2.6.2 from tarball

2009-07-01 Thread Paul Simon
subdirectories like "build", "Demo", "Doc", "Include", "Lib", etc. There are many files under /usr/bin/local/ which appear to be duplicates. This looks like a mess to me and would like some help to sort this out. Paul Simon -- http://mail.python.org/mailman/listinfo/python-list

Re: Open Source RSS Reader in Python?

2009-07-01 Thread Simon Forman
On Jul 1, 7:18 pm, Alex wrote: > I am looking for an open source RSS reader (desktop, not online) > written in Python but in vain. I am not looking for a package but a > fully functional software. > > Google: python "open source" (rss OR feeds) reader > > Any clue ? There's Canto: http://codezen.

Re: Need Help

2009-07-02 Thread Simon Brunning
ttp://catb.org/esr/faqs/smart-questions.html>. Our *four*...no... *Amongst* our links Amongst our linkry are such elements as <http://effbot.org/zone/unicode-objects.htm>, <http://www.joelonsoftware.com/articles/Unicode.html> I'll come in again. -- Cheers, Simon B. -- http://mail.python.org/mailman/listinfo/python-list

question of style

2009-07-02 Thread Simon Forman
Hey I was hoping to get your opinions on a sort of minor stylistic point. These two snippets of code are functionally identical. Which would you use and why? The first one is easier [for me anyway] to read and understand, but slightly less efficient, while the second is [marginally] harder to follo

Re: question of style

2009-07-02 Thread Simon Forman
On Jul 2, 1:44 pm, Duncan Booth wrote: > Simon Forman wrote: > > Hey I was hoping to get your opinions on a sort of minor stylistic > > point. > > These two snippets of code are functionally identical. Which would you > > use and why? > > The first one is e

Re: question of style

2009-07-02 Thread Simon Forman
On Jul 2, 4:08 pm, Erik Max Francis wrote: > Simon Forman wrote: > > Hey I was hoping to get your opinions on a sort of minor stylistic > > point. > > These two snippets of code are functionally identical. Which would you > > use and why? > > The first one is e

Re: question of style

2009-07-02 Thread Simon Forman
On Jul 2, 3:57 pm, Scott David Daniels wrote: > Duncan Booth wrote: > > Simon Forman wrote: > >> ... > >> if self.higher is self.lower is None: return > >> ... > > As a matter of style however I wouldn't use the shorthand to run two 'is' &

Re: What are the limitations of cStringIO.StringIO() ?

2009-07-02 Thread Simon Forman
On Wed, Jul 1, 2009 at 7:48 AM, Barak, Ron wrote: > Hi, > > I think I'm up against a limitation in cStringIO.StringIO(), but could not > find any clues on the web, especially not in > http://docs.python.org/library/stringio.html. > > What I have is the following function: > >     def concatenate_fi

Re: question of style

2009-07-02 Thread Simon Forman
On Jul 2, 9:30 pm, Paul Rubin <http://phr...@nospam.invalid> wrote: > Simon Forman writes: > > This code is part of a delete() method for a binary tree > > implementation. "None" is used to simulate a NULL pointer. In the case > > where both children are non

Re: getting rid of —

2009-07-02 Thread Simon Forman
t; Thanks! Okay people want to help you but you must make it easy for us. Post again with a small piece of code that is runnable as-is and that causes the traceback you're talking about, AND post the complete traceback too, as-is. I just tried a bit of your code above in my interpreter here

Re: PSP Caching

2009-07-03 Thread Simon Forman
appreciated. > > Johnson I don't know much about caching with apache, but the answer mght be on this page: http://httpd.apache.org/docs/2.2/caching.html Meanwhile, couldn't you just send apache a restart signal when you modify your code? HTH, ~Simon -- http://mail.python.org/mailman/listinfo/python-list

Re: question of style

2009-07-03 Thread Simon Forman
On Jul 3, 2:09 am, Lie Ryan wrote: > Simon Forman wrote: > > On Jul 2, 3:57 pm, Scott David Daniels wrote: > >> Duncan Booth wrote: > >>> Simon Forman wrote: > >>>> ... > >>>> if self.higher is self.lower is None: return > >>&

Re: question of style

2009-07-03 Thread Simon Forman
On Jul 3, 12:56 am, Paul Rubin <http://phr...@nospam.invalid> wrote: > Simon Forman writes: > > > Yes, but the concept of null pointers is considered kludgy these days. > > Seriously? "kludgy"?  (I really AM getting old.) > >  http://math.andrej.com/2

Re: Python debugger

2009-07-03 Thread Simon Forman
On Jul 3, 8:15 am, srinivasan srinivas wrote: > Hi, > Could you suggest some python debuggers? > > Thanks, > Srini > >       Love Cricket? Check out live scores, photos, video highlights and more. > Click herehttp://cricket.yahoo.com Ipython has good debugger integration. -- http://mail.python.

Re: question of style

2009-07-04 Thread Simon Forman
On Jul 4, 2:03 am, upwestdon wrote: > On Jul 2, 1:23 pm, Simon Forman wrote: > > > > > Hey I was hoping to get your opinions on a sort of minor stylistic > > point. > > These two snippets of code are functionally identical. Which would you > > use and why?

Re: question of style

2009-07-04 Thread Simon Forman
On Jul 4, 2:10 pm, Paul Rubin <http://phr...@nospam.invalid> wrote: > Simon Forman writes: > > > if not (self.higher and self.lower): > > >     return self.higher or self.lower > > > That would work too in this case, both higher and lower are expected >

Re: Clarity vs. code reuse/generality

2009-07-04 Thread Simon Forman
which is why you can (or should be able to without breaking your code) remove them entirely and know that your program will run identically. That's why folks are quick to jump on cases where assertions are used as control-flow constructs. (In your function, however, they aren't.) In a sense, assertions /are/ meaningless, except to the programmer. FWIW, you can use "if __debug__:" and put anything you like in the statement suite and the whole if statement goes away when run with '- O'. Sort of a "super-assert". Regards, ~Simon -- http://mail.python.org/mailman/listinfo/python-list

Re: Adding the Copy Property to a Simple Histogram

2009-07-05 Thread Simon Forman
On Jul 5, 9:48 pm, "W. eWatson" wrote: > The code below produces a text window 60hx20w with a scroll bar. The > contents are something of a histogram of values from 0 to 255. If one tries > to copy the contents, Windows doesn't allow it. What needs to be done to > allow a copy and paste? > >      

Re: generation of keyboard events

2009-07-06 Thread Simon Brunning
need to write a python > script which invokes my program and pass "Enter key" event to my > program so that it runs without manual intervention. Try <http://pywinauto.openqa.org/>. -- Cheers, Simon B. -- http://mail.python.org/mailman/listinfo/python-list

Re: Tree structure consuming lot of memory

2009-07-06 Thread Simon Forman
On Mon, Jul 6, 2009 at 6:12 AM, mayank gupta wrote: > Thanks for the other possibilites. I would consider option (2) and (3) to > improve my code. > > But out of curiosity, I would still like to know why does an object of a > Python-class consume "so" much of memory (1.4 kb), and this memory usage

Re: Newbie needs help

2009-07-07 Thread Simon Forman
dielectric constant" seems to be a dimensionless number, i.e. C/C... I could be totally daft though. HTH, ~Simon -- http://mail.python.org/mailman/listinfo/python-list

Re: Catching control-C

2009-07-07 Thread Simon Forman
On Jul 6, 6:02 pm, Michael Mossey wrote: > On Jul 6, 2:47 pm, Philip Semanchuk wrote: > > > On Jul 6, 2009, at 5:37 PM, Michael Mossey wrote: > > > > What is required in a python program to make sure it catches a   > > > control- > > > c on the command-line? Do some i/o? The OS here is Linux. > >

Re: Clarity vs. code reuse/generality

2009-07-07 Thread Simon Forman
On Tue, Jul 7, 2009 at 8:51 AM, Jean-Michel Pichavant wrote: > Steven D'Aprano wrote: >> >> On Tue, 07 Jul 2009 05:13:28 +, Lie Ryan wrote: >> >> >>> >>> When people are fighting over things like `sense`, although sense may >>> not be strictly wrong dictionary-wise, it smells of something burni

Re: automatic multiprocessing

2009-07-07 Thread Simon Forman
gs) function_outputs = cpus.map(f, function_inputs) (Note that f() could be defined outside the if statement if you're going to use it often.) HTH, ~Simon -- http://mail.python.org/mailman/listinfo/python-list

Re: tough-to-explain Python

2009-07-07 Thread Simon Forman
On Jul 7, 4:04 pm, kj wrote: > I'm having a hard time coming up with a reasonable way to explain > certain things to programming novices. > > Consider the following interaction sequence: > > >>> def eggs(some_int, some_list, some_tuple): > > ... some_int += 2 > ... some_list += [2] > ...

Re: ... remove all 0 values

2009-07-08 Thread Simon Forman
On Jul 8, 10:44 am, Daniel Austria wrote: > Hi python - hackers, > > just one question. How can i remove all 0 values in a list? Sure - i > can loop over it, but that s not a neat style.  list.remove() will > only remove the first occurence. Doing that while no exception is > raised is also uncool

tkinter problem

2009-07-08 Thread Paul Simon
only to the point of confusion. I'm not an expert. How do I modify my python configuration? Is there a file that needs to be edited? Which setup.py file do I use? Make? or python setup.py build and python setup.py install? Thanks. I appreciate your help. Paul Simon -- http://mail.python.org/mailman/listinfo/python-list

Re: tkinter problem

2009-07-08 Thread Paul Simon
"Chris Rebert" wrote in message news:mailman.2863.1247095339.8015.python-l...@python.org... On Wed, Jul 8, 2009 at 4:18 PM, Paul Simon wrote: > I have the "tkinter" problem and need some assistance to straighten it > out. > >From the web page "http://wiki.

Re: tough-to-explain Python

2009-07-08 Thread Simon Forman
(I wanted to reply to a few messages in one post so I quoted them all below. Let me know if this is bad etiquette.) On Jul 8, 8:23 am, kj wrote: > In <5f0a2722-45eb-468c-b6b2-b7bb80ae5...@q11g2000yqi.googlegroups.com> Simon > Forman writes: > > >Frankly, I'm of

Re: tkinter problem

2009-07-09 Thread Paul Simon
"Peter Otten" <__pete...@web.de> wrote in message news:h3481q$d95$0...@news.t-online.com... > Paul Simon wrote: > >> "Chris Rebert" wrote in message >> news:mailman.2863.1247095339.8015.python-l...@python.org... >> On Wed, Jul 8, 2009 at

Re: can i write a assemly language programs in python

2009-07-09 Thread Simon Forman
Python applications, or export them to standard assembly languages." HTH, ~Simon -- http://mail.python.org/mailman/listinfo/python-list

Re: gett error message: "TypeError: 'int' object is not callable"

2009-07-09 Thread Simon Forman
ed in the last few years) HTH, ~Simon -- http://mail.python.org/mailman/listinfo/python-list

Re: tkinter problem

2009-07-10 Thread Paul Simon
"David Smith" wrote in message news:h35f78$pt...@ruby.cit.cornell.edu... > Paul Simon wrote: >> "Peter Otten" <__pete...@web.de> wrote in message >> news:h3481q$d95$0...@news.t-online.com... >>> Paul Simon wrote: >>> >>>>

Re: Python code for testing well parenthesized expression

2009-07-19 Thread Simon Forman
On Jul 14, 1:10 pm, Duncan Booth wrote: > John Machin wrote: > > Try an iterative version of checking that () [] and {} > > are balanced and nested appropriately. > > Here's how I might approach the more general case: > > def balanced(s, parens=("()",)): >     ''' >     Example: >     >>> balance

Re: tough-to-explain Python

2009-07-20 Thread Simon Forman
. But I'm glad it's there to study, these are wheels I don't have to invent for myself. ~Simon -- http://mail.python.org/mailman/listinfo/python-list

Re: tough-to-explain Python

2009-07-20 Thread Simon Forman
ing programs logically. Making the formal methods explicit gives you the strongest available confidence that you are reasoning, and programming, correctly. This is not to say that "incorrect" (or unproven or unprovable) programs are never useful or necessary. However, I do feel that it's

Re: invoke method on many instances

2009-07-21 Thread Simon Forman
27;method', 1, 2, foo=3)", number=1000) > timeit.timeit(setup="from __main__ import apply1,apply2,L",   > stmt="apply2(L,'method', 1, 2, foo=3)", number=1000) > > > -- > Gabriel Genellina If your instances are all of the same class

Re: tough-to-explain Python

2009-07-21 Thread Simon Forman
On Mon, Jul 20, 2009 at 9:54 PM, Paul Rubin<http://phr...@nospam.invalid> wrote: > Simon Forman writes: >> But I'm glad it's there to study, these are wheels I don't have to >> invent for myself. > > http://dwheeler.com/essays/high-assurance-floss.html

Re: Help understanding the decisions *behind* python?

2009-07-21 Thread Simon Forman
and the types of the fields are implied by use, not explicitly declared.) (FWIW: http://en.wikipedia.org/wiki/Record_(computer_science) ) Broadly speaking, lists are useful for things like stacks and queues, and sorting, while tuples are useful for aggregating heterogeneous data into coherent units, and you can hash them (provided their contents are also hashable.) HTH, ~Simon -- http://mail.python.org/mailman/listinfo/python-list

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

2009-07-21 Thread Simon Forman
On Jul 21, 5:00 pm, 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 correc

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

2009-07-21 Thread Simon Forman
On Jul 21, 5:53 pm, davidj411 wrote: > On Jul 21, 5:29 pm, Simon Forman wrote: > > > > > On Jul 21, 5:00 pm, davidj411 wrote: > > > > I am using a recursive function to print the time and a few other > > > things on each pass. ( the function calc

Re: iText for Python

2009-07-27 Thread Simon Brunning
module with Python and I am > thinking of doing this in as my final year project also. Kindly give > me your suggestion. What would this give us that ReportLab does not? I wouldn't want to see you spend a lot of time reinventing the wheel... -- Cheers, Simon B. -- http://mail.python.org/

Re: Very Strange Problem

2009-07-30 Thread Simon Forman
On Wed, Jul 29, 2009 at 3:10 PM, Omer Khalid wrote: > Hi Dave, > > Thanks for your reply. I actually didn't cut and paste my code as it was > dispersed in different places, i typed the logic behind my code in the email > (and obiviously made some typos, indentations is some thing else) but my Plea

Re: unique-ifying a list

2009-08-09 Thread Simon Forman
On Aug 7, 4:53 pm, kj wrote: > Suppose that x is some list.  To produce a version of the list with > duplicate elements removed one could, I suppose, do this: > >     x = list(set(x)) > > but I expect that this will not preserve the original order of > elements. > > I suppose that I could write so

Re: Search and write to .txt file

2009-08-11 Thread Simon Forman
be too difficult, but I don't know how. > < > Help appreciated! There's a bug in this line: if line.find('1'): the string find() method returns an integer, which will be -1 if the substring is not found. In python -1 is treated as True (only 0 is False) so your if stat

Re: dictionary help

2009-08-11 Thread Simon Forman
On Aug 11, 11:51 am, MRAB wrote: > Krishna Pacifici wrote: > > Thanks for the help. > > > Actually this is part of a much larger project, but I have unfortunately > > pigeon-holed myself into needing to do these things without a whole lot > > of flexibility. > > > To give a specific example I have

Re: Need cleanup advice for multiline string

2009-08-12 Thread Simon Brunning
;http://tinyurl.com/c5nqju> and many more), I'm sorry to say that I don't think this is funny. -- Cheers, Simon B. -- http://mail.python.org/mailman/listinfo/python-list

Re: Need cleanup advice for multiline string

2009-08-12 Thread Simon Forman
On Aug 12, 10:41 am, Robert Dailey wrote: > On Aug 12, 9:09 am, exar...@twistedmatrix.com wrote: > > > > > On 01:27 pm, jeanmic...@sequans.com wrote: > > > >Simon Brunning wrote: > > >>2009/8/11 Robert Dailey : > > >>>On Aug 11, 3:

Re: problem with interface of operator.itemgetter

2009-08-16 Thread Simon Forman
gt; table1 ] > > so is there a way to force itemgetter to return tuple even when > itemgetter(only_have_one_argument)? or some other function to do this? > > Thanks. > You can use a little helper function to create your itemgetter like this: def makeItemGetter(indexes): I = ite

Re: Splitting a string into substrings of equal size

2009-08-16 Thread Simon Forman
On Aug 14, 8:22 pm, candide wrote: > Suppose you need to split a string into substrings of a given size (except > possibly the last substring). I make the hypothesis the first slice is at the > end of the string. > A typical example is provided by formatting a decimal string with thousands > separ

Re: comparing XML files to eachother

2009-08-18 Thread Simon Forman
On Mon, Aug 17, 2009 at 3:51 PM, David Brochu wrote: > I need to compare one xml document to another to see if the content matches. > Unfortunately, the formatting (spacing) and order of elements may change > between files from run to run. I have looked into xml dom minidom but can't > seem to find

Re: define class over 2 files

2009-08-18 Thread Simon Forman
On Tue, Aug 18, 2009 at 1:57 AM, Steven D'Aprano wrote: > On Mon, 17 Aug 2009 21:45:57 -0700, naveen wrote: > >> Is it possible to split up a class definition over multiple files? > > Not exactly, but you can do variations of this: > > > In file A.py, create: > > class Parent: >    def method(self)

Re: Need cleanup advice for multiline string

2009-08-18 Thread Simon Forman
On Tue, Aug 18, 2009 at 1:05 PM, Jean-Michel Pichavant wrote: > Steve Holden wrote: Robert Dailey: >> >> [...] >> >>> >>> It's a figure of speech. And besides, why would I want programming >>> advice from a woman? lol. Thanks for the help. >>> >> >> Sorry, Robert, simply not acceptab

Re: Inheriting dictionary

2009-08-18 Thread Simon Forman
rt partial def getter(first, second, key): try: return first(key) except KeyError: return second(key) f = partial(getter, b.__getitem__, a.__getitem__) # Or, if you know you'll be getting a lot of KeyErrors, you # can use get() instead of __getitem__(). def getter1(first, second, key, sentinel=None): item = first(key, sentinel) if item is sentinel: item = second(key) return item g = partial(getter1, b.get, a.__getitem__) HTH, ~Simon -- http://mail.python.org/mailman/listinfo/python-list

Re: Inheriting dictionary

2009-08-18 Thread Simon Forman
On Tue, Aug 18, 2009 at 6:08 PM, Simon Forman wrote: > On Aug 18, 3:44 pm, Pavel Panchekha wrote: >> I want a dictionary that will transparently "inherit" from a parent >> dictionary. So, for example: >> >> """ >> a = InheritDict({1: &quo

Re: Need cleanup advice for multiline string

2009-08-18 Thread Simon Forman
On Tue, Aug 18, 2009 at 8:03 PM, Steven D'Aprano wrote: > On Tue, 18 Aug 2009 17:13:02 -0400, Simon Forman wrote: > >> Sexism, racism, homophobia, religious intolerance, etc., all stem from a >> fundamental forgetfulness of our Unity in God (as I would put it) and > >

Re: Need cleanup advice for multiline string

2009-08-18 Thread Simon Forman
On Tue, Aug 18, 2009 at 8:42 PM, Ben Finney wrote: > Simon Forman writes: > >> Sexism, racism, homophobia, religious intolerance, etc., all stem from >> a fundamental forgetfulness of our Unity in God (as I would put it) > > It seems odd, for someone who cites religious

Re: recording input from USB port and write to text file

2009-08-19 Thread Simon Forman
On Aug 18, 7:33 pm, Allan wrote: > Hi! I'm fairly new to Python.  I understand the basics basics but I'm > been trying to write a simple python code that will let me read input > data (such as mouse movement) from my USB port and write it in a text > file and I am so lost.  Can anyone help or dire

Re: Need cleanup advice for multiline string

2009-08-19 Thread Simon Forman
On Aug 19, 12:05 am, Ben Finney wrote: > Simon Forman writes: > > On Tue, Aug 18, 2009 at 8:42 PM, Ben Finney > > wrote: > > > We're all unified by our humanity. Bringing any god into the picture > > > is surely counter to any goals of unity. > > >

Re: #elements of seq A in seq B

2009-08-19 Thread Simon Forman
(a, b): a = set(a) d = defaultdict(int) for item in b: if item in a: d[item] += 1 return d print g(A, B) # prints defaultdict(, {' ': 1, 'e': 1, 'g': 1, 'i': 1, 'o': 1, 'n': 2, 's': 1, 'r': 2, 't': 2}) HTH, ~Simon -- http://mail.python.org/mailman/listinfo/python-list

Re: #elements of seq A in seq B

2009-08-19 Thread Simon Forman
On Aug 19, 11:34 pm, John Machin wrote: > On Aug 20, 12:12 pm, Simon Forman wrote: > > > On Aug 19, 8:17 pm, "Jan Kaliszewski" wrote: > > > If you mean: to count non overlaping occurences of string A in B > > > -- simply: > > > >    B.count(A

Re: Annoying octal notation

2009-08-20 Thread Simon Forman
On Aug 20, 3:06 pm, David <71da...@libero.it> wrote: > Hi all, > > Is there some magic to make the 2.x CPython interpreter to ignore the > annoying octal notation? No. You would have to modify and recompile the interpreter. This is not exactly trivial, see "How to Change Python's Grammar" http://

Re: incrementing string/hex value from file and write back

2009-08-20 Thread Simon Forman
the optional base. It is an error to supply a base when converting a | non-string. If the argument is outside the integer range a long object | will be returned instead. | | Methods defined here: | ... Unfortunately you can't use it on the '%' string formatting operator... >>> help(%) SyntaxError: invalid syntax So here's a link to the docs: http://docs.python.org/library/stdtypes.html#string-formatting-operations HTH, ~Simon -- http://mail.python.org/mailman/listinfo/python-list

Re: incrementing string/hex value from file and write back

2009-08-20 Thread Simon Forman
On Aug 20, 5:18 pm, "Rami Chowdhury" wrote: > > val = val.encode('hex') > > That's the crucial line -- it's returning a new integer, which you are   > re-binding to val. If you then did: No, it returns another string, which still isn't the decimal representation of the hex string. hex C => decim

Re: Object Reference question

2009-08-21 Thread Simon Forman
#x27;x': 1} I don't understand what you're trying to do, but give up the idea of "object reference memory locations". Any name binding in python just associates a string with a object in one of various namespace dictionaries. HTH, ~Simon -- http://mail.python.org/mailman/listinfo/python-list

<    10   11   12   13   14   15   16   >