Re: Implementing chain of responsibility

2009-03-09 Thread Chris Rebert
On Sun, Mar 8, 2009 at 11:53 PM, koranthala wrote: > Hi, >    I want to implement chain of responsibility pattern in Python (for > a Django project) >    The problem that I see is a rather odd one - how to link the > subclasses with the super class. Grabbing out my copy of Head First Design Patte

Re: a potential pep to extend the syntax of for loops

2009-03-09 Thread Chris Rebert
On Mon, Mar 9, 2009 at 2:15 AM, pang wrote: >  Hello, >  This is an idea about something I'd like to see implemented in > python. > I understand that's the purpose of PEPs, so I'll write it as a PEP, > but > send it here to receive your valuable feedback. > > Abstract > > This is a proposal to inc

Re: Ban Xah Lee

2009-03-09 Thread Chris Rebert
On Mon, Mar 9, 2009 at 4:12 AM, Larry Gates wrote: > On Sun, 08 Mar 2009 04:09:52 +, Dirk Bruere at NeoPax wrote: > >> Dirk Bruere at NeoPax wrote: > >>> Well, don't worry - nobody is going to ban you from Usenet (except >>> possibly the Chinese govt). >>> OTOH, nobody here much cares. >>> So,

Re: Is python worth learning as a second language?

2009-03-09 Thread Chris Rebert
On Mon, Mar 9, 2009 at 3:43 AM, ZikO wrote: > Hi > > I hope I won't sound trivial with asking my question. > > I am a C++ programmer and I am thinking of learning something else because I > know second language might be very helpful somehow. I have heard a few > positive things about Python but I

Re: Implementing chain of responsibility

2009-03-09 Thread Chris Rebert
On Mon, Mar 9, 2009 at 3:54 AM, koranthala wrote: > On Mar 9, 12:16 pm, Chris Rebert wrote: >> On Sun, Mar 8, 2009 at 11:53 PM, koranthala wrote: >> > Hi, >> >    I want to implement chain of responsibility pattern in Python (for >> > a Django project) >&g

Re: Read from .csv file

2009-03-09 Thread Chris Rebert
On Mon, Mar 9, 2009 at 1:56 PM, Karnama Ahmad (KTH) wrote: > > Dear all, > > I would be thankfukl if you answer to the following easy question: > > How can I read from a .csv file in Python and save the data in a array > or dictionary. Use the `csv` module -- http://docs.python.org/library/csv.ht

Re: Concurrent tasklets in Stackless Python

2009-03-09 Thread Chris Rebert
On Mon, Mar 9, 2009 at 3:05 PM, Minesh Patel wrote: > Is there a way for multiple tasklets to run in parallel? Seems doubtful (though I'm not an expert). From the Wikipedia article: "Stackless microthreads are managed by the language interpreter itself, not the operating system kernel—context sw

Re: docstring reference to another docstring

2009-03-09 Thread Chris Rebert
On Mon, Mar 9, 2009 at 3:23 PM, bdb112 wrote: > A function of the class ClusterSet uses a similar function of the > class Cluster to do most of its work.  Its docstring could have so > much in common with that in Cluster that it could be just a line or > two in addition to that of Cluster. > > Is

Re: docstring reference to another docstring

2009-03-09 Thread Chris Rebert
On Mon, Mar 9, 2009 at 4:17 PM, bdb112 wrote: > Thanks for the quick reply - I expanded it to a working program, > it seems to do the job and works in my actual code (always good).  As > you said, it assumes the called function's class is already defined. > Is there a way around this? (The mo

Re: Concurrent tasklets in Stackless Python

2009-03-09 Thread Chris Rebert
On Mon, Mar 9, 2009 at 4:47 PM, Minesh Patel wrote: > On Mon, Mar 9, 2009 at 3:17 PM, Chris Rebert wrote: >> On Mon, Mar 9, 2009 at 3:05 PM, Minesh Patel wrote: >>> Is there a way for multiple tasklets to run in parallel? >> >> Seems doubtful (though I'm not a

Re: searching strings

2009-03-09 Thread Chris Rebert
On Mon, Mar 9, 2009 at 6:18 PM, Daniel Dalton wrote: > Hi, > > I'm writing a program where I search a variable (path), and see if it > contains the whole string of variable name > so: > if name in path: >   > else: >   > > One question about this, how can I make it do exactly what it's doi

Re: Number Sequencing, Grouping and Filtering

2009-03-10 Thread Chris Rebert
On Tue, Mar 10, 2009 at 2:54 AM, flebber wrote: > Hi > > I was hoping someone would be able to point me in the direction of > some good documentation regarding sequencing, grouping and filtering > and in which order they should be done. > > As a small example it is easy to create the range of numb

Re: Number Sequencing, Grouping and Filtering

2009-03-10 Thread Chris Rebert
On Tue, Mar 10, 2009 at 3:00 AM, flebber wrote: > On Mar 10, 8:54 pm, flebber wrote: >> Hi >> >> I was hoping someone would be able to point me in the direction of >> some good documentation regarding sequencing, grouping and filtering >> and in which order they should be done. >> >> As a small e

Re: urllib2.URLError:

2009-03-11 Thread Chris Rebert
On Tue, Mar 10, 2009 at 11:34 PM, Coonay wrote: > i use python2.6 > > > File "C:\PROGRA~1\Python26\lib\urllib2.py", line 383, in open >    response = self._open(req, data) >  File "C:\PROGRA~1\Python26\lib\urllib2.py", line 401, in _open >    '_open', req) >  File "C:\PROGRA~1\Python26\lib\urllib2

Re: calling class methods from class methods, help?

2009-03-11 Thread Chris Rebert
On Wed, Mar 11, 2009 at 10:08 AM, Oltmans wrote: > I've a multithreaded program in which I've to call class methods from > class methods. Um, those are instance methods, not class methods. Class methods take the class itself as an argument (the parameter is typically named "cls" instead of "self"

Re: Can python (CPython) and IPython coexist normally on the same computer ?

2009-03-11 Thread Chris Rebert
On Wed, Mar 11, 2009 at 4:17 PM, scoop wrote: > I know I could just try to install it and see, but I've got my > configuration just right, so I don't want to mess it up (maybe) with > IPython. > > Also, can someone please point me to some page where I can find > differences between C and I Python.

Re: unbiased benchmark

2009-03-12 Thread Chris Rebert
On Thu, Mar 12, 2009 at 1:07 PM, Sam Ettessoc wrote: > I would like to share a benchmark I did. The computer used was a > 2160MHz Intel Core Duo w/ 2000MB of 667MHz DDR2 SDRAM running MAC OS > 10.5.6 and a lots of software running (a typical developer > workstation). > > Python benchmark: > HAMBUR

Re: converting a string to a function parameter

2009-03-13 Thread Chris Rebert
On Fri, Mar 13, 2009 at 12:52 AM, koranthala wrote: > Hi, >    Is it possible to convert a string to a function parameter? > Ex: > str = 'True, type=rect, sizes=[3, 4]' > and I should be able to use it as: > test(convert(str)) and the behaviour should be same as calling test > with those values :

Re: Python package for .ics (iCalendar) files

2009-03-13 Thread Chris Rebert
On Fri, Mar 13, 2009 at 3:05 PM, wrote: > Is there an 'offical' Python package for handling .ics files or is the > follwing the best there is:- > >    http://codespeak.net/icalendar/ > > It seems rather old but Google didn't pop anything else up. Well, the iCalendar standard doesn't really chang

Re: How to interface with C# without IronPython

2009-03-13 Thread Chris Rebert
On Fri, Mar 13, 2009 at 3:51 PM, Mudcat wrote: > All the topics I seem to find on this topic lead me in the direction > of IronPython, but I'm not interested right now in a reimplementation > of Python in .Net environment. There are wrappers and methods > available for integrating with Java, C, an

Re: Parameter sublists [was: An ordering question]

2009-03-13 Thread Chris Rebert
On Fri, Mar 13, 2009 at 5:30 PM, Peter Pearson wrote: > On Fri, 13 Mar 2009 18:56:30 +0100, Hrvoje Niksic wrote: > [snip] >> a.sort(key=lambda (x, y): b[y - 1], reverse=True) > > Huh?  I had no idea one could do this: > def g( ( ( x, y ), z ) ): > ...   return y > ... g( ((1,2),3) ) > 2

Re: python book for a C programmer

2009-03-14 Thread Chris Rebert
On Fri, Mar 13, 2009 at 10:29 PM, Paul Rubin wrote: > Saurabh writes: >> Hi all, >> I am an experienced C programmer, I have done some perl code as well. >> But while thinking about large programs,I find perl syntax a >> hinderance. > > I would say read the online tutorial, then "Python in a Nuts

Re: How to add months to a date (datetime object)?

2009-03-15 Thread Chris Rebert
On Sun, Mar 15, 2009 at 10:28 AM, wrote: > I have a date in the form of a datetime object and I want to add (for > example) three months to it.  At the moment I can't see any very > obvious way of doing this.  I need something like:- > >    myDate = datetime.date.today() >    inc = datetime.timed

Re: How to add months to a date (datetime object)?

2009-03-15 Thread Chris Rebert
On Sun, Mar 15, 2009 at 11:00 AM, wrote: > Roy Smith wrote: >> In article <49bd3ab8$0$510$bed64...@news.gradwell.net>, tinn...@isbd.co.uk >> wrote: >> >> > I have a date in the form of a datetime object and I want to add (for >> > example) three months to it.  At the moment I can't see any very

Re: How to add months to a date (datetime object)?

2009-03-15 Thread Chris Rebert
On Sun, Mar 15, 2009 at 1:30 PM, Roy Smith wrote: > In article , >  Chris Rebert wrote: > >> Which makes some sense considering a month can range from 28-31 days, >> which would make the delta oddly fuzzy. > > BTW, what date is "One month after August 10, 1752&quo

Re: Set overlapping

2009-03-15 Thread Chris Rebert
On Sun, Mar 15, 2009 at 1:41 PM, mattia wrote: > How can I determine the common values found in two differents sets and > then assign this values? > E.g. > dayset = ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"] > monthset = ["Jan", "Feb", "Apr", "May", "Jun", "Jul", "Aug", "Sep", > "Oct", "Nov

Re: How to add months to a date (datetime object)?

2009-03-15 Thread Chris Rebert
On Sun, Mar 15, 2009 at 4:17 PM, Steve Holden wrote: > Roy Smith wrote: >> In article <49bd3ab8$0$510$bed64...@news.gradwell.net>, tinn...@isbd.co.uk >> wrote: >> >>> I have a date in the form of a datetime object and I want to add (for >>> example) three months to it.  At the moment I can't see a

Re: Correct URL encoding

2009-03-15 Thread Chris Rebert
On Sun, Mar 15, 2009 at 4:21 PM, mattia wrote: > I'm using urlopen in order to download some web pages. I've always to > replace some characters that are in the url, so I've come up with: > url.replace("|", "%7C").replace("/", "%2F").replace(" ", "+").replace > (":", "%3A") > There isn't a better

Re: Correct URL encoding

2009-03-15 Thread Chris Rebert
On Sun, Mar 15, 2009 at 4:54 PM, gervaz wrote: > On Mar 16, 12:38 am, Graham Breed wrote: >> mattia wrote: >> > I'm using urlopen in order to download some web pages. I've always to >> > replace some characters that are in the url, so I've come up with: >> > url.replace("|", "%7C").replace("/", "

Re: Problem while copying a file from a remote filer

2009-03-15 Thread Chris Rebert
On Sun, Mar 15, 2009 at 10:24 PM, venutaurus...@gmail.com wrote: > Hi all, >      I have to write an application which does a move and copy of a > file from a remote machine to the local machine. I tried something > like: > > file = ur"venuwin2008\\C\\4Folders\\Folder02\\Folder002\ > \TextFile

Re: Newbie question: How do I add elements to **kwargs in a function?

2009-03-16 Thread Chris Rebert
On Mon, Mar 16, 2009 at 7:48 PM, Aaron Garrett wrote: > I have spent quite a bit of time trying to find the answer on this > group, but I've been unsuccessful. Here is what I'd like to be able to > do: > > def A(**kwargs): >    kwargs['eggs'] = 1 > > def B(**kwargs): >    print(kwargs) > > def C(*

Re: Can python quickly display results like bash?

2009-03-17 Thread Chris Rebert
On Mon, Mar 16, 2009 at 6:05 PM, robert song wrote: > Hello, everyone. > python can be debugged with pdb, but if there anyway to get a quick > view of the python execution. > Just like sh -x of bash command. > I didn't find that there is an option of python that can do it. I've read the manpage f

Re: Can python quickly display results like bash?

2009-03-17 Thread Chris Rebert
On Tue, Mar 17, 2009 at 11:13 AM, D'Arcy J.M. Cain wrote: > On Tue, 17 Mar 2009 11:10:36 -0700 > Chris Rebert wrote: >> I've read the manpage for bash and can find no such -x option listed. > > It's an option from sh(1) that bash copies.  Check the man page for s

Re: Can python quickly display results like bash?

2009-03-17 Thread Chris Rebert
On Tue, Mar 17, 2009 at 12:15 PM, Hrvoje Niksic wrote: > Chris Rebert writes: > >> Ah, I should've thought to google for the sh manpage. Locally, man >> sh just gives me the bash manpage again which doesn't list -x :-( > > Are you sure?  On my system the OPTI

Re: Is their an expression to create a class?

2009-03-17 Thread Chris Rebert
On Tue, Mar 17, 2009 at 2:24 PM, Robert Kern wrote: > On 2009-03-17 16:13, Paddy wrote: >> >> We the def statement and the lambda expression. We have the class >> statement, but is their an expression to create a class? >> >> Or: >> > def F(): pass >> > type(F) >> >> > > # Is to:

Re: Python to Perl transalators

2009-03-17 Thread Chris Rebert
2009/3/17 : > Could anyone suggest whether there is any Python to Perl code convertors? > I found one on the net viz. Perthon. But it wasn’t really helping out. Why on earth would you want to? That'd be like translating Shakespeare into a bad rap song! Cheers, Chris -- I have a blog: http://

Re: File Compare with difflib.context_diff

2009-03-18 Thread Chris Rebert
On Wed, Mar 18, 2009 at 2:30 PM, JohnV wrote: > I have a txt file that gets appended with data over a time event.  The > data comes from an RFID reader and is dumped to the file by the RFID > software.  I want to poll that file several times over the time period > of the event to capture the curre

Re: what does 64-bit python mean?

2009-03-18 Thread Chris Rebert
On Wed, Mar 18, 2009 at 11:45 PM, srinivasan srinivas wrote: > > Hi, > Could someone help me in understanding what 64-bit python means? It's been compiled for 64-bit processors, so it uses 64-bit pointers and 64-bit small integers. And I would think it would only work w/ C extension libraries als

Re: Do deep inheritance trees degrade efficiency?

2009-03-19 Thread Chris Rebert
On Wed, Mar 18, 2009 at 6:09 AM, Anthra Norell wrote: > Would anyone who knows the inner workings volunteer to clarify whether or > not every additional derivation of a class hierarchy adds an indirection to > the base class's method calls and attribute read-writes. In C++, I suppose, > a three-le

Re: Do deep inheritance trees degrade efficiency?

2009-03-19 Thread Chris Rebert
On Thu, Mar 19, 2009 at 2:54 AM, Christian Heimes wrote: > Chris Rebert wrote: >> There's no effect on attribute read-writes as they all take place >> within the single __dict__ of the instance. As for method lookup, it >> doesn't add an indirection per se, bu

Re: Emulate a printf() C-statement in Python???

2009-03-19 Thread Chris Rebert
On Thu, Mar 19, 2009 at 5:43 AM, Mr. Z wrote: > I'm trying emulate a printf() c statement that does, for example > > char* name="Chris"; > int age=30; > printf("My name is %s", name); > printf("My name is %s and I am %d years old.", %s, %d); > > In other words, printf() has a variable arguement li

Re: Emulate a printf() C-statement in Python???

2009-03-19 Thread Chris Rebert
On Thu, Mar 19, 2009 at 6:13 AM, John Machin wrote: > On Mar 19, 11:52 pm, Chris Rebert wrote: >> On Thu, Mar 19, 2009 at 5:43 AM, Mr. Z wrote: >> > I'm trying emulate a printf() c statement that does, for example >> >> > char* name="Chris"; &g

Re: Preferred syntax for the docstrings

2009-03-19 Thread Chris Rebert
On Thu, Mar 19, 2009 at 6:26 AM, Luis Zarrabeitia wrote: > > What's the preferred style to document code in python? I usually do something > like this: > > === > def somefunction(arg1, arg2, out = sys.stdout): >    """ This function does blahblablha with the string arg1, using >    the tuple of in

Re: How to use self-inspection to check for try-block

2009-03-20 Thread Chris Rebert
On Fri, Mar 20, 2009 at 1:32 AM, wrote: > Hi everyone, > > is there a sufficiently easy possibility for a Python function to find > out whether it has been called from a try-block or not? > > try: >  print "Calling foo" >  foo() > except: >  print "Got exception" > > In the example above, foo() s

Re: How to use self-inspection to check for try-block

2009-03-20 Thread Chris Rebert
On Fri, Mar 20, 2009 at 2:09 AM, wrote: > On Mar 20, 9:44 am, Chris Rebert wrote: >> On Fri, Mar 20, 2009 at 1:32 AM,   wrote: >> > Hi everyone, >> >> > is there a sufficiently easy possibility for a Python function to find >> > out whether

Re: locate items in matrix (index of lists of lists)

2009-03-20 Thread Chris Rebert
On Fri, Mar 20, 2009 at 3:50 AM, Alexzive wrote: > Hello there, > > let's suppose I have the following matrix: > > mat = [[1,2,3], [3,2,4], [7,8,9], [6,2,9]] > > where [.. , .. , ..] are the rows. > > I am interested into getting the "row index" of all the matrix rows > where a certain number occu

Re: locate items in matrix (index of lists of lists)

2009-03-20 Thread Chris Rebert
On Fri, Mar 20, 2009 at 4:34 AM, Alessandro Zivelonghi wrote: > Many Thanks guys! > > and what if I need to look ONLY into the second and third columns, > excluding the first item of each rows? > > for example if x = 3 I need to get  [0] and not [0,1] indices = [i for i, row in enumerate(mat) if

Re: locate items in matrix (index of lists of lists)

2009-03-20 Thread Chris Rebert
On Fri, Mar 20, 2009 at 7:28 AM, MRAB wrote: > Chris Rebert wrote: >> >> On Fri, Mar 20, 2009 at 4:34 AM, Alessandro Zivelonghi >> wrote: >>> >>> Many Thanks guys! >>> >>> and what if I need to look ONLY into the second and third column

Re: url lib

2009-03-20 Thread Chris Rebert
On Fri, Mar 20, 2009 at 10:07 AM, CSUIDL PROGRAMMEr wrote: > Hello > I am a novice python progammer > > I am just writing a script that will automatically write my /etc/ > yum.repos.d/* files in linux. > > the problem is i am trying to connect to a secure repo and pass > username and password to t

Re: nested classes

2009-03-20 Thread Chris Rebert
2009/3/20 Benjamin Kaplan : > > > On Fri, Mar 20, 2009 at 10:06 AM, Esmail wrote: >> >> Hello all, >> >> I am curious why nested classes don't seem to be used much in Python. >> I see them as a great way to encapsulate related information, which is >> a >> good thing. >> >> In my other post "impro

Re: Is there any way for a program to choose between 32 bit or 64-bit python dynamically?

2009-03-20 Thread Chris Rebert
On Fri, Mar 20, 2009 at 6:28 AM, srinivasan srinivas wrote: > > Hi, > Is thera any way for a program to choose between 32-bit or 64-bit dynamically? Doubt it, since it's set in stone from when your CPython interpreter got compiled. There may be some workaround to use 32bit libs from a 64-bit prog

Re: nested classes

2009-03-20 Thread Chris Rebert
On Fri, Mar 20, 2009 at 1:24 PM, Esmail wrote: > On Mar 20, 2:41 pm, Chris Rebert wrote: >> 2009/3/20 Benjamin Kaplan : >> > On Fri, Mar 20, 2009 at 10:06 AM, Esmail wrote: >> >> >> Hello all, >> >> >> I am curious why nested classes don&#

Re: simplejson: alternate encoder not called enought

2009-03-22 Thread Chris Rebert
On Sat, Mar 21, 2009 at 2:11 PM, Pierre Hanser wrote: > hello > > I'm trying to use simplejson to encode some > python objects using simplejson dumps method. > > The dumps method accept a cls parameter to specify > an alternate encoder. But it seems that this alternate > encoder is called only as

Re: Using python 3 for scripting?

2009-03-22 Thread Chris Rebert
2009/3/22 Timo Myyrä : > Hi, > > I'll have to do some scripting in the near future and I was thinking on using > the Python for it. I would like to know which version of Python to use? Is > the Python 3 ready for use or should I stick with older releases? 2.6.1, the latest non-3.x release is pro

Re: regular expressions, stack and nesting

2009-03-22 Thread Chris Rebert
2009/3/22 Aaron Brady : > Hi, > > Every so often the group gets a request for parsing an expression.  I > think it would be significantly easier to do if regular expressions > could modify a stack.  However, since you might nearly as well write > Python, maybe there is a compromise. If you need to

Re: Calendar module: HTMLCalendar overrides style sheet settings

2009-03-28 Thread Chris Rebert
On Fri, Mar 27, 2009 at 6:24 PM, Gabriel Genellina wrote: > En Fri, 27 Mar 2009 17:48:33 -0300, Sibylle Koczian > escribió: > >> Terry Reedy schrieb: >>> >>> Calendar is an ancient and not-well-maintained module which may even >>> predate html.  (There have even been suggestions that it be droppe

Re: Understanding JSON

2009-03-29 Thread Chris Rebert
On Sun, Mar 29, 2009 at 1:39 PM, WallyDD wrote: > Hello, > > I am trying to geocode some map data using the google maps API. > > By using the urllib I can get the JSON output; > http://maps.google.com/maps/geo?q=New+York+USA&output=json&oe=utf8&sensor=true&key=your_api_key > > I then read it using

Re: email from windows

2009-03-29 Thread Chris Rebert
2009/3/29 prakash jp : > Hi all, > > In windows environment, how to send email from one gmail address to another > gmail (or another mail) addrress Use the `smtplib` and `email` standard libraries (which, as a bonus, are cross-platform): http://docs.python.org/library/smtplib.html http://docs.pyth

Re: global name 'self' is not defined - noob trying to learn

2009-03-29 Thread Chris Rebert
On Sun, Mar 29, 2009 at 9:18 PM, wrote: > Hi.  So now I have this class that works to allow me to pass in my > reg_info struct.  However when I try to make it part of my class it > gets an error "global name 'self' is not defined.  I've never seen > this error before.  If I comment out the line b

Re: global name 'self' is not defined - noob trying to learn

2009-03-29 Thread Chris Rebert
2009/3/29 Scott David Daniels : > mark.sea...@gmail.com wrote: >> >> On Mar 29, 9:52 pm, Chris Rebert wrote: >>> >>> On Sun, Mar 29, 2009 at 9:18 PM,   wrote: >>>> >>>> ... >>> >>> ... Also, you shouldn't use `cl

Re: Problems with code

2009-03-30 Thread Chris Rebert
2009/3/30 Zach Goscha : > Hi, > > I am trying to call an unbound method (Map.Background) but getting the > following error: >  TypeError: unbound method background() must be called with Map instance as > first argument (got nothing instead) > > Here is some of the code(not completed) > > Thanks in

Re: problem with urllib

2009-03-31 Thread Chris Rebert
2009/3/31 venkat sanaka : > hii everyone > > I am new to python programming.And i started implementing a http client > using urllib in which > i was facing a problem with proxy support.i was behind a proxy server and > need to use > proxy of format 10.1.2.21:8080 to connect to internet.when i used

Re: problem with urllib

2009-03-31 Thread Chris Rebert
> On Wed, Apr 1, 2009 at 4:35 AM, Chris Rebert wrote: >> >> 2009/3/31 venkat sanaka : >> > hii everyone >> > >> > I am new to python programming.And i started implementing a http client >> > using urllib in which >> > i was facing a pro

Re: python for loop

2009-03-31 Thread Chris Rebert
On Tue, Mar 31, 2009 at 5:24 PM, Lada Kugis wrote: > I'm coming from fortran and c background so I'm certainly biased by > them. But if you could explain one thing to me: > > in fortran for example: > for i=1,n > goes from 1,2,3,4,...,n > > in python for example: > for i in range(1,n) > goes from

Re: python for loop

2009-03-31 Thread Chris Rebert
On Tue, Mar 31, 2009 at 5:48 PM, Lada Kugis wrote: > On Wed, 01 Apr 2009 11:42:20 +1100, Ben Finney > wrote: > >>Lada Kugis writes: >> >>> in python for example: >>> for i in range(1,n) >>> goes from 1,2,3,4,...,n-1 >>> (that is, it goes from 1 up to, but not including n) >> >>Also, ?range(n)? c

Re: python for loop

2009-03-31 Thread Chris Rebert
On Tue, Mar 31, 2009 at 7:13 PM, Lada Kugis wrote: > On Tue, 31 Mar 2009 21:13:05 -0400 (CLT), "andrew cooke" > wrote: > >>Lada Kugis wrote: >>> I'm coming from fortran and >>   *** c *** >>> background so I'm certainly biased by >>> them. But if you could explain one thing to me:

Re: Python Goes Mercurial

2009-04-01 Thread Chris Rebert
On Wed, Apr 1, 2009 at 12:01 AM, Carl Banks wrote: > On Mar 31, 6:25 pm, Lawrence D'Oliveiro central.gen.new_zealand> wrote: >> >> >> So what were these "strong antipathies" towards Git, exactly? > > Apparently Mercurial h

Re: Demographic Information about Python

2009-04-01 Thread Chris Rebert
2009/4/1 Betiana Krancenblum : > Hi, > > I'm looking for statistical information about where Python is beeing used as > a programming language and where it is teached as a language for beginner > programmers. > Where do you think I can find that information? I don't think there are any statistics

Re: Tab completion

2009-04-02 Thread Chris Rebert
On Thu, Apr 2, 2009 at 7:59 AM, Steven D'Aprano wrote: > Does anyone use the tab-completion recipe in the docs? > > http://docs.python.org/library/rlcompleter.html#module-rlcompleter > > suggests using this to enable tab-completion: > > try: >    import readline > except ImportError: >    print "M

Re: PEP 382: Namespace Packages

2009-04-02 Thread Chris Rebert
On Thu, Apr 2, 2009 at 11:38 AM, Carl Banks wrote: > On Apr 2, 8:32 am, "Martin v. Löwis" wrote: >> I propose the following PEP for inclusion to Python 3.1. >> Please comment. >> >> Regards, >> Martin >> >> Abstract >> >> >> Namespace packages are a mechanism for splitting a single Pytho

Re: config parser -help

2009-04-03 Thread Chris Rebert
> On Fri, Apr 3, 2009 at 3:15 PM, Murali kumar wrote: >> >> hi all, >> >> i want to all my configuration file names in current/user/home directory.. >> >> for that i came across following function in configparser class.. >> Is it must to specify file names? or only directories enough.. >> if there

Re: Let-expressions

2009-04-03 Thread Chris Rebert
On Fri, Apr 3, 2009 at 4:18 PM, Terry Reedy wrote: > sloisel wrote: >> >> Dear All, >> >> I searched this group and found that there have been discussions about >> introducing a let expression to the language so that you can define >> local variables in a lambda. I.e., something like f=lambda x: l

Re: Accessing mail box tree of Thunderbird/Seamonkey?

2009-04-05 Thread Chris Rebert
On Sun, Apr 5, 2009 at 1:04 AM, robert wrote: > Is there a API/possibilty for reading&writing (live) in the mail box tree of > Thunderbird/Seamonkey with Python? >From what I can google, they're already in mbox format, so you can use mailbox.mbox to read/write to them. See http://docs.python.org/

Re: Module Names with . (dots)?

2009-04-05 Thread Chris Rebert
On Sun, Apr 5, 2009 at 11:41 AM, activescott wrote: > My understanding is that module names must not have a dot in them. For > example, I tried to create a module like scott.appengine.util.py  and > put misc utility classes in there. However, python gives the error "No > module named scott.appengi

Re: Best way to start

2009-04-06 Thread Chris Rebert
On Mon, Apr 6, 2009 at 12:08 PM, Avi wrote: > Hi, > > What is a good way to learn Python? > > Do you recommend going by a book (suggestions welcome) or learning > with tutorials? Both? The official Python tutorial is pretty darn good: http://docs.python.org/tutorial/ If you want a book as well, I

Re: print from a python script.

2009-04-06 Thread Chris Rebert
On Mon, Apr 6, 2009 at 2:24 PM, Ronn Ross wrote: > I'm trying to print a simple string to a network printer. This is what I > have so far: > > import os > > printer_path = "192.168.200.139" > p = os.popen(printer_path, 'w') > p.write("this is a printer test") > p.close() > > I'm trying to call the

Re: Web validation

2009-04-06 Thread Chris Rebert
On Mon, Apr 6, 2009 at 3:44 PM, r-w wrote: > If no internet connection: Try loading http://example.com using urllib (http://docs.python.org/library/urllib.html). If an exception gets raised, you're not connected (properly). Cheers, Chris -- I have a blog: http://blog.rebertia.com -- http://mai

Re: decorator module in stdlib?

2009-04-06 Thread Chris Rebert
On Mon, Apr 6, 2009 at 5:41 PM, Daniel Fetchinson wrote: > The decorator module [1] written by Michele Simionato is a very useful > tool for maintaining function signatures while applying a decorator. > Many different projects implement their own versions of the same > functionality, for example t

Re: pseudo-code

2009-04-07 Thread Chris Rebert
On Tue, Apr 7, 2009 at 2:00 AM, r-w wrote: > If no internet connection: >    if have files: >        run anyway, with warning >    else: >        ERROR > else: >    if error getting hash/files: >        if have files: >            run anyway, with warning >        else: >            ERROR >    els

Re: Help with setting up Tkinter

2009-04-08 Thread Chris Rebert
On Wed, Apr 8, 2009 at 1:15 AM, Eclipse wrote: import _tkinter import Tkinter Tkinter._test > That last input line should be: Tkinter._test() Note the parens, which do matter (Python != Ruby/Smalltalk). Try again and see if you get an actual error. Cheers, Chris -- I have a b

Re: Floor value in math operators

2009-04-08 Thread Chris Rebert
On Wed, Apr 8, 2009 at 9:03 AM, Avi wrote: > Hi, > > This will be a very simple question to ask all the awesome programmers > here: > > How can I get answer in in decimals for such a math operator: > > 3/2 > > I get 1. I want to get 1.5 Add the following line to the top of your program (or use Py

Re: calculate field in ARCGIS

2009-04-09 Thread Chris Rebert
On Thu, Apr 9, 2009 at 12:42 PM, Lydia wrote: > Hi Python users, > > I ran into a problem with python coding in ARCGIS. Does anybody have the > experience in dealing with this? > > I need to calculate NEWFIELD based on OLDFIELD under condition: if  OLDFIELD > == 0 then return string "B" otherwise

Re: newbie ``print`` question

2012-09-02 Thread Chris Rebert
On Sun, Sep 2, 2012 at 10:23 AM, gwhite wrote: > I can't figure out how to stop the "add a space at the beginning" > behavior of the print function. > print 1,;print 2, > 1 2 > > See the space in between the 1 and the 2 at the output print to the > command console? > > The help for print is:

Re: newbie ``print`` question

2012-09-02 Thread Chris Rebert
On Sun, Sep 2, 2012 at 1:24 PM, Mark Lawrence wrote: > On 02/09/2012 20:58, me wrote: >> >> Well you can convert the ints to str then concatenate them. >> >> print "1" + "2" >> > > Please post other parts of the thread so people can get the context or don't > bother posting at all, thanks. Please

Re: get the matched regular expression position in string.

2012-09-03 Thread Chris Rebert
On Mon, Sep 3, 2012 at 1:18 AM, contro opinion wrote: > Subject: get the matched regular expression position in string. As is often the case in Python, string methods suffice. Particularly for something so simple, regexes aren't necessary. > Here is a string : > > str1="ha,hihi,a,ok" > > I w

Re: subprocess call is not waiting.

2012-09-13 Thread Chris Rebert
On Thu, Sep 13, 2012 at 11:36 AM, wrote: > Thanks, guys. > MRAB-RedHat 6 64-bit, Python 2.6.5 In your Unix shell, what does the command: type htar output? > JM-Here's the relevant stuff from my last try. If you could give a complete, self-contained example, it would assist us in troublesho

Re: subprocess call is not waiting.

2012-09-13 Thread Chris Rebert
On Thu, Sep 13, 2012 at 8:17 AM, wrote: > I have a subprocess.call > But it doesn't work as intended. > Should I just go back to os.system? Did the os.system() version work? As of recent Python versions, os.system() is itself implemented using the `subprocess` module, so if it does work, then

Re: subprocess call is not waiting.

2012-09-14 Thread Chris Rebert
On Fri, Sep 14, 2012 at 5:22 AM, wrote: > os.system worked fine, and I found something in another section of code that > was causing the "Too many open errors." (I was fooled, because output from > subprocess call didn't seem to be coming out until the open files error. > > I'll go back and pla

Re: datetime issue

2012-09-15 Thread Chris Rebert
On Sat, Sep 15, 2012 at 10:33 AM, Νικόλαος Κούρας wrote: > Hello again, > > one small matter too. > > # get some enviromental values > locale.setlocale(locale.LC_ALL, 'el_GR') > date = datetime.datetime.now().strftime( '%y-%m-%d %H:%M:%S' ) > > although iam setting greek as locale Locales don't

Re: 'indent'ing Python in windows bat

2012-09-17 Thread Chris Rebert
On Mon, Sep 17, 2012 at 8:28 PM, Dennis Lee Bieber wrote: > On Mon, 17 Sep 2012 21:08:32 -0400, David Smith > declaimed the following in gmane.comp.python.general: > >> >> How do I "indent" if I have something like: >> if (sR=='Cope'): sys.exit(1) elif (sR=='Perform') sys.exit(2) else >> sys.exit

Re: Passing arguments to & executing, a python script on a remote machine from a python script on local machine (using ssh ?)

2012-09-20 Thread Chris Rebert
On Wed, Sep 19, 2012 at 12:50 PM, ashish wrote: > 2. I have a python script, local.py, running on 'local' which needs to pass > arguments ( 3/4 string arguments, containing whitespaces like spaces, etc ) > to a python script, remote.py running on 'remote' (the remote machine). > 3. Has anybody

Re: python idioms : some are confusing

2012-09-20 Thread Chris Rebert
On Thu, Sep 20, 2012 at 10:34 PM, Vineet wrote: > Amongst the python idioms, how the below-mentioned make sense? These aren't idioms (that term has a specific technical meaning in programming); they're *way* too abstract to be idioms. "Design principles" or "design guidelines" would be a better d

Re: Functional way to compare things inside a list

2012-09-21 Thread Chris Rebert
On Fri, Sep 21, 2012 at 1:23 AM, Chris Angelico wrote: > On Fri, Sep 21, 2012 at 8:58 AM, wrote: > That gets the result, but probably not in the cleanest way. I'm not > sure off-hand if Python has a convenient way to curry a function, http://docs.python.org/library/functools.html#functools.par

Re: Functional way to compare things inside a list

2012-09-21 Thread Chris Rebert
On Thu, Sep 20, 2012 at 3:58 PM, wrote: > Hi, > > list = [{'1': []}, {'2': []}, {'3': ['4', '5']}] Are the dictionaries each guaranteed to only contain a single key-value pair? (Or is your example just simplistic?) > I want to check for a value (e.g. '4'), and get the key of the dictionary > th

Re: For Counter Variable

2012-09-25 Thread Chris Rebert
On Tue, Sep 25, 2012 at 2:46 AM, Mark Lawrence wrote: > On 25/09/2012 10:32, wxjmfa...@gmail.com wrote: >> >> I wrote my first program on a PDP-8. I discovered Python >> at release 1.5.? >> >> Now years later... I find Python more and more unusable. >> I'm toying more and more with the go languag

Re: How to pass FILE *

2012-09-28 Thread Chris Rebert
On Fri, Sep 28, 2012 at 2:55 PM, xDog Walker wrote: > > The function I am trying to call wants a FILE *: > > dlg_progressbox(const char *title, > const char *cprompt, > int height, > int width, > int pauseopt, > FILE *

Re: Why is pylaucher in Python 3.3 being installed in Windows folder?

2012-10-03 Thread Chris Rebert
On Wed, Oct 3, 2012 at 8:21 PM, Ian Kelly wrote: > On Wed, Oct 3, 2012 at 8:04 PM, Steven D'Aprano > wrote: >> On Wed, 03 Oct 2012 14:13:10 -0700, Piotr Dobrogost wrote: >> >>> Why is pylauncher in Python 3.3 being installed in Windows folder and >>> not in Program Files folder? Installing into W

Re: Can somebody give me an advice about what to learn?

2012-10-03 Thread Chris Rebert
On Wed, Oct 3, 2012 at 11:31 AM, Wolfgang Keller wrote: >> I'm really new to Usenet/Newsgroups, but... I'd like to learn some >> new programming language, because I learnt a bit of Perl though its >> OOP is ugly. So, after searching a bit, I found Python and Ruby, and >> both of they are cute. So,

Re: Unpaking Tuple

2012-10-06 Thread Chris Rebert
On Sat, Oct 6, 2012 at 3:09 AM, sajuptpm wrote: > Hi, > > I am using python 2.6. > > I need a way to make following code working without any ValueError . a, b, c, d = (1,2,3,4) a, b, c, d = (1,2,3). > > Note: Number of values in the tuple will change dynamically. Then you arguably want

Re: question on log as an instance method

2012-10-07 Thread Chris Rebert
On Sun, Oct 7, 2012 at 1:33 AM, Franck Ditter wrote: > Hi ! Here is Python 3.2.3, MacOSX-Lion > > Question 0 : I may consider + as an hidden instance method , as > 1+2 is equivalent to (1).__add__(2) ? No, it's not nearly that simple. It's technically equivalent to operator.add(1, 2) [ http://doc

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