Re: Exceptions: Logging TB and local variables?

2007-10-10 Thread allen.fowler
> Two possibilieies: > > You will need to determine ALL the exceptions that the 3rd party party modules > can raise. If they are custom exceptions you will need to import them into > your > application from their modules. > > example: > > say that 3rd party modules raise TransientError, IOError,

Re: "".join(string_generator()) fails to be magic

2007-10-10 Thread Marc 'BlackJack' Rintsch
On Thu, 11 Oct 2007 01:26:04 -0500, Matt Mackal wrote: > I have an application that occassionally is called upon to process > strings that are a substantial portion of the size of memory. For > various reasons, the resultant strings must fit completely in RAM. > Occassionally, I need to join some

Re: storing meta data on dictionary keys

2007-10-10 Thread Andreas Kraemer
On Oct 10, 9:00 pm, Erik Jones <[EMAIL PROTECTED]> wrote: > If you're sure that 1. this use case won't grow and 2. that you'll > only be the only person ever using code, then it's your choice of > preference. Both of those points are equally important. 1 is a > manageability issue in that you ar

"".join(string_generator()) fails to be magic

2007-10-10 Thread Matt Mackal
I have an application that occassionally is called upon to process strings that are a substantial portion of the size of memory. For various reasons, the resultant strings must fit completely in RAM. Occassionally, I need to join some large strings to build some even larger strings. Unfortunately,

Re: Keeping track of subclasses and instances?

2007-10-10 Thread Thomas Heller
Karlo Lozovina schrieb: > Hi, > > what's the best way to keep track of user-made subclasses, and instances of > those subclasses? I just need a pointer in a right direction... thanks. > New style classes have a __subclasses__ class method that shows the direct subclasses: Python 2.4.4 (#71, Oc

CGI and external JavaScript nightmare

2007-10-10 Thread IamIan
My website is built from a Python CGI and works great. I'm now including Google Ads, which requires two pieces of JavaScript; the first contains the display settings for the ads, and the second piece is a very lengthy garbled js file at http://pagead2.googlesyndication.com/pagead/show_ads.js The

Re: Duck Typing and **kwds

2007-10-10 Thread Kay Schluehr
On 11 Okt., 06:05, Luis Zarrabeitia <[EMAIL PROTECTED]> wrote: > Is that behavior expected? Is there any reason (performance, perhaps?) to > break > duck-typing in this situation? I guess it wasn't considered to be relevant writing a coercion function since there aren't too many dict like types

Re: Keeping track of subclasses and instances?

2007-10-10 Thread Andreas Kraemer
On Oct 10, 6:19 pm, Karlo Lozovina <[EMAIL PROTECTED]> wrote: > Larry Bates wrote: > > I'm not completely sure I understand the question but here goes. > > Instances of > > classes are classes can be stored in lists or dictionaries. In lists you > > reference them via their index (or iterate over

Re: M2Crypto possible intermittent bug

2007-10-10 Thread John Nagle
Heikki Toivonen wrote: > John Nagle wrote: >> Still having trouble reproducing the problem. But somewhere, >> something raised that bogus no-error exception three times. >> Anything that returns "(0, 'Error')" as exception data is a bug. > > If you can, build python and m2crypto with debug sym

Re: Keeping track of subclasses and instances?

2007-10-10 Thread Steven D'Aprano
On Wed, 10 Oct 2007 21:35:44 -0700, Michele Simionato wrote: > On Oct 10, 8:17 pm, Karlo Lozovina <[EMAIL PROTECTED]> wrote: >> Hi, >> >> what's the best way to keep track of user-made subclasses, and >> instances of those subclasses? I just need a pointer in a right >> direction... thanks. >> >>

Re: Can I overload the compare (cmp()) function for a Lists ([]) index function?

2007-10-10 Thread alan . haffner
On Sep 28, 5:12 pm, Hrvoje Niksic <[EMAIL PROTECTED]> wrote: > xkenneth <[EMAIL PROTECTED]> writes: > > Looking to do something similair. I'm working with alot of timestamps > > and if they're within a couple seconds I need them to be indexed and > > removed from a list. > > Is there any possible w

urllib.ProxyHandler HTTPS issues

2007-10-10 Thread Devraj
Hi everyone, I have been reading various documents/posts on the web about handling proxy options in urllib2. Some of them suggest that urllib2 doesn't handle HTTPS and others say it does. I have successfully written code that relays HTTP connections via a proxy but have failed to do the same for H

ANN: Chandler 0.7.1

2007-10-10 Thread Heikki Toivonen
The Chandler Project is pleased to announce the 0.7.1 release of Chandler Desktop! Chandler Desktop is an open source, standards-based personal information manager (PIM) built around small group collaboration and a core set of information management workflows modeled on Inbox usage patterns and Da

Re: Keeping track of subclasses and instances?

2007-10-10 Thread Michele Simionato
On Oct 10, 8:17 pm, Karlo Lozovina <[EMAIL PROTECTED]> wrote: > Hi, > > what's the best way to keep track of user-made subclasses, and instances of > those subclasses? I just need a pointer in a right direction... thanks. > > -- > Karlo Lozovina -- Mosor This recipe does what you want, with the in

Re: How to "dereference" an iterator?

2007-10-10 Thread Robert Dailey
Thanks! Yellow is my favorite color! On 10/10/07, Pablo Ziliani <[EMAIL PROTECTED]> wrote: > > Robert Dailey wrote: > > (...) > > What I was actually trying to accomplish was to iterate over 2 > > iterators using 1 for loop, however I found that the zip() function > > allows me to do this quite ea

Duck Typing and **kwds

2007-10-10 Thread Luis Zarrabeitia
Hi there. I just tried this test: def f(**kwds): print kwds import UserDict d = UserDict.UserDict(hello="world") f(**d) And it fails with a TypeError exception ("f() argument after ** must be a dictionary"). I find that weird, as UserDict should support all protocols that dict su

Re: howto add a sub-directory to the searchpath / namespace ?

2007-10-10 Thread [david]
r" indicates a 'regular expression' string, normally called a raw string. It means that \ characters are treated using the regex syntax rather than the c syntax. In the regex syntax, \ characters are escape characters only at the end of the string, which allows you to easily use Windows directory

Re: storing meta data on dictionary keys

2007-10-10 Thread Erik Jones
On Oct 10, 2007, at 6:40 PM, Andreas Kraemer wrote: > On Oct 9, 9:18 pm, Erik Jones <[EMAIL PROTECTED]> wrote: >> So, do you not keep references to your nodes anywhere but the actual >> graph dict? I kind of agree with Chris here in that two dicts will >> work. One for the nodes, indexed by thei

Re: for loop question

2007-10-10 Thread Steven D'Aprano
On Wed, 10 Oct 2007 20:25:00 +, Paul Hankin wrote: >> A "works-for-me": >> >> >>> pairs = (test[i:i+2] for i in xrange(len(test)-1)) >> >>> for a,b in pairs: >> ... print a,b > > for a, b in zip(test, test[1:]): > print a, b May be unfortunately slow if test is half a gigabyte of da

Re: Version specific or not?

2007-10-10 Thread Scott David Daniels
Steven W. Orr wrote: > We have an app and I'm trying to decide where the app ... . > /usr/lib/python2.3/site-packages > or > /usr/lib/site-python > > The latter would solve a lot of problems for me. Fewer than you suspect > If there are multiple versions of python installed on the same machine,

a good website for softwares,movies and music ,sex etc.

2007-10-10 Thread panguohua
www.space666.com good -- http://mail.python.org/mailman/listinfo/python-list

Re: How to "dereference" an iterator?

2007-10-10 Thread Robert Dailey
Hi, I suppose my question in general is goofy to native python programmers. I'm originally a C++ programmer and I have a hard time not relating iterators in python to iterators in STL lol. What I was actually trying to accomplish was to iterate over 2 iterators using 1 for loop, however I found th

Re: Problems with struct.pack()

2007-10-10 Thread Robert Dailey
Hi, Thanks for responding. I apologize about my lack of details, I was in a hurry when I wrote the initial question. I'll provide more details. Basically, I'm attempting to write out unicode strings (16 bits per character) to a file. Before each string, I write out 4 bytes containing the number o

Re: I'm starting to think like a Pythonista

2007-10-10 Thread Erik Jones
On Oct 10, 2007, at 4:16 PM, Marc 'BlackJack' Rintsch wrote: > On Wed, 10 Oct 2007 17:03:41 -0400, brad wrote: > >> Bjoern Schliessmann wrote: >>> brad wrote: low_odds = [1,3,5,7,9] # make a list containing 10 - 98 evens only big_evens = big_evens = [x for x in list(xrange(99)) if

Re: Keeping track of subclasses and instances?

2007-10-10 Thread Steven D'Aprano
On Thu, 11 Oct 2007 03:19:07 +0200, Karlo Lozovina wrote: > Here is a longer description - I have a function that given input > creates a custom class and returns it back. The user is free to subclass > that (even more, he should do that), and of course he will make > instances of those subclasses

Re: if then elif

2007-10-10 Thread Steven D'Aprano
On Wed, 10 Oct 2007 20:42:26 -0600, Michael L Torrie wrote: > [EMAIL PROTECTED] wrote: > > >> that's the most incorrect thing i've heard all day! >> >> if cal or fat <= 0 is parsed as if (cal) or (fat <= 0) > > Which is exactly what he said. Heh, that was my first thought too, for about 3.2 m

Re: How to "dereference" an iterator?

2007-10-10 Thread Steven D'Aprano
The original post seems to have been eaten, so I'm replying via a reply. Sorry for breaking threading. > On Wed, 2007-10-10 at 18:01 -0500, Robert Dailey wrote: >> Hi, >> >> Suppose I wanted to manually iterate over a container, for example: >> >> mylist = [1,2,3,4,5,6] >> >> it = iter(mylist)

Re: Keeping track of subclasses and instances?

2007-10-10 Thread George Sakkis
On Oct 10, 9:19 pm, Karlo Lozovina <[EMAIL PROTECTED]> wrote: > Larry Bates wrote: > > I'm not completely sure I understand the question but here goes. > > Instances of > > classes are classes can be stored in lists or dictionaries. In lists you > > reference them via their index (or iterate over

Re: if then elif

2007-10-10 Thread Michael L Torrie
[EMAIL PROTECTED] wrote: > > that's the most incorrect thing i've heard all day! > > if cal or fat <= 0 is parsed as if (cal) or (fat <= 0) Which is exactly what he said. He also said that what the poster probably wanted was if cal <= 0 or fat <=0 > -- http://mail.python.org/mailman/listi

Re: Python Magazine: Issue 1 Free!

2007-10-10 Thread Steve Holden
Daniel Klein wrote: > On Fri, 05 Oct 2007 07:44:46 -0400, Steve Holden <[EMAIL PROTECTED]> > wrote: > >> I've just been told by the editors at Python Magazine that the first >> issue is out. It's all-electronic so anyone can download and read it. > > The website states that existing subcribers

Re: Singleton

2007-10-10 Thread Steven D'Aprano
On Wed, 10 Oct 2007 17:37:53 +0200, Diez B. Roggisch wrote: >> Two borgs, or two million, the whole point of using borgs is that it >> doesn't matter. > > It does matter where the classes live (module-wise). Which is the > problem the OP had, borg or not to borg. Gotcha. Thanks for the demonstr

Re: Singleton

2007-10-10 Thread Steven D'Aprano
On Wed, 10 Oct 2007 09:52:26 -0700, Carl Banks wrote: > On Oct 10, 11:18 am, Steven D'Aprano <[EMAIL PROTECTED] > cybersource.com.au> wrote: >> Of course, if there is some other meaning to the OP's post, then >> possibly I've completely misunderstood it. Would you mind telling me >> what you've se

RE: Problem of Readability of Python

2007-10-10 Thread Delaney, Timothy (Tim)
Licheng Fang wrote: > This is enlightening. Surely I shouldn't have worried too much about > performance before doing some measurement. And with that statement you have truly achieved enlightenment. Or to put it another way ... performance tuning without profiling is a waste of time. Tim Delane

RE: Fwd: NUCULAR fielded text searchable indexing

2007-10-10 Thread Delaney, Timothy (Tim)
[EMAIL PROTECTED] wrote: >> From: Grant Edwards >> >> Anyway, I apologize for my attempt at humor, since it appears >> to have somehow offended. > > Why apologize? If someone doesn't like the name given to a piece of > software by its author(s), screw them. If I find the software useful, > I'l

Re: Keeping track of subclasses and instances?

2007-10-10 Thread Karlo Lozovina
Larry Bates wrote: > I'm not completely sure I understand the question but here goes. > Instances of > classes are classes can be stored in lists or dictionaries. In lists you > reference them via their index (or iterate over them) and in dictionaries > you can give them a name that is used as a

Re: multimethods decorator

2007-10-10 Thread gherzig
> Gerardo Herzig a écrit : >> Hi all. Im reading the Gido's aproach using decorators at >> http://www.artima.com/weblogs/viewpost.jsp?thread=101605 >> >> It looks good to me, but the examples shows the functionality using >> functions. >> Now, when i try to give this decorator into a method, if i t

Re: Keeping track of subclasses and instances?

2007-10-10 Thread Larry Bates
Karlo Lozovina wrote: > Hi, > > what's the best way to keep track of user-made subclasses, and instances of > those subclasses? I just need a pointer in a right direction... thanks. > I'm not completely sure I understand the question but here goes. Instances of classes are classes can be stored

Re: hi every one

2007-10-10 Thread Dustan
On Oct 10, 7:19 pm, kasim <[EMAIL PROTECTED]> wrote: > Dear __, >>> __.dear() Traceback (most recent call last): File "", line 1, in __.dear() NameError: name '__' is not defined >>> __ = self >>> __.dear() Traceback (most recent call last): File "", line 1, in

Re: Python Magazine: Issue 1 Free!

2007-10-10 Thread Daniel Klein
On Fri, 05 Oct 2007 07:44:46 -0400, Steve Holden <[EMAIL PROTECTED]> wrote: >I've just been told by the editors at Python Magazine that the first >issue is out. It's all-electronic so anyone can download and read it. The website states that existing subcribers are notified of the availability o

Re: Problems with struct.pack()

2007-10-10 Thread Carsten Haese
On Wed, 2007-10-10 at 19:00 -0500, Robert Dailey wrote: > Hi, > > I have opened a unicode file for writing: > > import codecs > file = codecs.open( "somefile.dat", "wb", "utf-16" ) > > and I attempt to do this: > > file.write( struct.pack ( "I", 5000 ) ) > > However, this won't work because th

hi every one

2007-10-10 Thread kasim
www.agloco.com/r/BBFR6434 http://www.yuwie.com/yuwie.asp?r=102001 Dear __, I recently joined AGLOCO because of a friend recommended it to me. I am now promoting it to you because I like the idea and I want you to share in what I think will be an exciting new Internet concept. AGLOCO's story

Keeping track of subclasses and instances?

2007-10-10 Thread Karlo Lozovina
Hi, what's the best way to keep track of user-made subclasses, and instances of those subclasses? I just need a pointer in a right direction... thanks. -- Karlo Lozovina -- Mosor -- http://mail.python.org/mailman/listinfo/python-list

Problems with struct.pack()

2007-10-10 Thread Robert Dailey
Hi, I have opened a unicode file for writing: import codecs file = codecs.open( "somefile.dat", "wb", "utf-16" ) and I attempt to do this: file.write( struct.pack( "I", 5000 ) ) However, this won't work because the encoding of the string returned by "pack" isn't unicode. I'm a bit confused rig

Re: storing meta data on dictionary keys

2007-10-10 Thread Andreas Kraemer
On Oct 9, 9:18 pm, Erik Jones <[EMAIL PROTECTED]> wrote: > So, do you not keep references to your nodes anywhere but the actual > graph dict? I kind of agree with Chris here in that two dicts will > work. One for the nodes, indexed by their strings. Yes, I guess that's exactly what I want. To kee

Re: Really basic problem

2007-10-10 Thread Ricardo Aráoz
tomamil wrote: > i know this example is stupid and useless, but that's not the answer > to my question. > here it goes: > > status = 0.0 > for i in range(10): >status = status + 0.1 > >if status == 0.1: >print status >elif status == 0.2: >print status >elif status

Re: How to "dereference" an iterator?

2007-10-10 Thread Carsten Haese
On Wed, 2007-10-10 at 18:01 -0500, Robert Dailey wrote: > Hi, > > Suppose I wanted to manually iterate over a container, for example: > > mylist = [1,2,3,4,5,6] > > it = iter(mylist) > while True: > print it > it.next() > > In the example above, the print doesn't print the VALUE that th

Re: if then elif

2007-10-10 Thread thebjorn
On Oct 10, 11:03 pm, Larry Bates <[EMAIL PROTECTED]> wrote: [...] > > Boolean problem: > > if cal or fat <= 0 > > That may be the way you say it or "think" it but it won't work. > > 'cal or fat' is evaluated first. Since they both have values this ALWAYS > evaluates to 1 which is NEVER less than o

Re: M2Crypto possible intermittent bug

2007-10-10 Thread Heikki Toivonen
John Nagle wrote: > Still having trouble reproducing the problem. But somewhere, > something raised that bogus no-error exception three times. > Anything that returns "(0, 'Error')" as exception data is a bug. If you can, build python and m2crypto with debug symbols, and place breakpoints in |

Re: howto add a sub-directory to the searchpath / namespace ?

2007-10-10 Thread stef mientki
Larry Bates wrote: > stef mientki wrote: > >> hello, >> >> my program has become a bit large, >> and now I want to split the files over several subdirectories. >> So in the example shown below, I just moved the files f1.py and f2.py to >> a deeper subdirectory. >> >> basedirectory\ >>mainfi

How to "dereference" an iterator?

2007-10-10 Thread Robert Dailey
Hi, Suppose I wanted to manually iterate over a container, for example: mylist = [1,2,3,4,5,6] it = iter(mylist) while True: print it it.next() In the example above, the print doesn't print the VALUE that the iterator currently represents, it prints the iterator itself. How can I get th

Re: PYTHONPATH on OS X

2007-10-10 Thread Graham Dumpleton
On Oct 11, 8:00 am, "mhearne808[insert-at-sign-here]gmail[insert-dot- here]com" <[EMAIL PROTECTED]> wrote: > I'm missing something major here. I'm trying to add a directory to my > python path using the PYTHONPATH environment variable, and it's being > ignored by the Python interactive shell. > >

Re: PYTHONPATH on OS X

2007-10-10 Thread Anthony
On Oct 10, 11:00 pm, "mhearne808[insert-at-sign-here]gmail[insert-dot- here]com" <[EMAIL PROTECTED]> wrote: > I'm missing something major here. I'm trying to add a directory to my > python path using the PYTHONPATH environment variable, and it's being > ignored by the Python interactive shell. > >

Re: M2Crypto possible intermittent bug

2007-10-10 Thread John Nagle
John Nagle wrote: > John Nagle wrote: >> I just "upgraded" from M2Crypto 0.17 to M2Crypto 0.18, and I'm >> running my regression tests. I'm seeing occasional cases where >> M2Crypto raises the exception SSL.SSLError, and the associated >> error is "(0, 'Error')", which is the bogus error you get

Re: Really basic problem

2007-10-10 Thread Dan Stromberg
On Mon, 08 Oct 2007 12:23:27 +0200, A.T.Hofkamp wrote: > On 2007-10-08, Andreas Tawn <[EMAIL PROTECTED]> wrote: >>> i know this example is stupid and useless, but that's not the answer >>> to my question. >>> here it goes: >>> >> You've just discovered the joys of floating point number comparison

Re: if then elif

2007-10-10 Thread chris . monsanto
On Oct 10, 5:03 pm, Larry Bates <[EMAIL PROTECTED]> wrote: > Shawn Minisall wrote: > > I just learned about if, then elif statements and wrote this program. > > The problem is, it's displaying all of the possibilities even after you > > enter a 0, or if the fat grams are more then the total number

Re: PYTHONPATH on OS X

2007-10-10 Thread Diez B. Roggisch
mhearne808[insert-at-sign-here]gmail[insert-dot-here]com schrieb: > I'm missing something major here. I'm trying to add a directory to my > python path using the PYTHONPATH environment variable, and it's being > ignored by the Python interactive shell. > > Below is a capture of what I did. Note

Re: RMI with Pyro et al

2007-10-10 Thread Diez B. Roggisch
Sells, Fred schrieb: > I need a simple client/server architecture with clients on linux and servers > on windows. There is no UI in this part, just business rules and access > control. > > Pyro seems pretty cool for this due to it's simplicity. I'm just starting > with it and have not been ab

Re: Pythonic way for handling file errors

2007-10-10 Thread danielx
On Oct 10, 12:28 pm, Paul Hankin <[EMAIL PROTECTED]> wrote: > On Oct 10, 7:41 pm, wink <[EMAIL PROTECTED]> wrote: > > > I would like to know what would be considered the most > > Pythonic way of handling errors when dealing with files, > > solutions that seem reasonable using 2.5: > > The best way

PYTHONPATH on OS X

2007-10-10 Thread mhearne808[insert-at-sign-here]gmail[insert-dot-here]com
I'm missing something major here. I'm trying to add a directory to my python path using the PYTHONPATH environment variable, and it's being ignored by the Python interactive shell. Below is a capture of what I did. Note that my newfolder appears nowhere on the list of directories in sys.path. H

Re: for loop question

2007-10-10 Thread Robert Dailey
On 10/10/07, Carsten Haese <[EMAIL PROTECTED]> wrote: > > Instead of passing the file object directly to the csv parser, pass in a > generator that reads from the file and explicitly encodes the strings > into UTF-8, along these lines: > > def encode_to_utf8(f): > for line in f: > yield

Re: Problem of Readability of Python

2007-10-10 Thread Steven Bethard
Bjoern Schliessmann wrote: > Kevin wrote: >> Am I missing something, or am I the only one who explicitly >> declares structs in python? > > Yes -- you missed my posting :) Actually, your posting just used dicts normally. Kevin is creating a prototype dict with a certain set of keys, and then co

Re: I'm starting to think like a Pythonista

2007-10-10 Thread Marc 'BlackJack' Rintsch
On Wed, 10 Oct 2007 17:03:41 -0400, brad wrote: > Bjoern Schliessmann wrote: >> brad wrote: >>> low_odds = [1,3,5,7,9] >>> # make a list containing 10 - 98 evens only >>> big_evens = big_evens = [x for x in list(xrange(99)) if x % 2 == >>> 0 and x >8] >> >> Why use xrange if you convert it to a

Re: for loop question

2007-10-10 Thread Carsten Haese
On Wed, 2007-10-10 at 16:03 -0500, Robert Dailey wrote: > I've tried everything to make the original CSV module work. It just > doesn't. I've tried UTF-16 encoding What do you mean, "tried?" Don't you know what the file is encoded in? > (which works fine with codecs.open()) but when I pass in th

Re: I'm starting to think like a Pythonista

2007-10-10 Thread brad
Erik Jones wrote: > big_evens = range(10, 100, 2) > big_odds = range(11, 100, 2) Neat, but not as clever or as hard to read as mine... I'll bet it faster though... maybe not. The upto part is here: ok_numbers = low_odds + big_evens + [x for x in low_evens if x <= y] -- http://mail.python.org

Re: unpickle from URL problem

2007-10-10 Thread Hrvoje Niksic
Alan Isaac <[EMAIL PROTECTED]> writes: > Hrvoje Niksic wrote: >> The first upload breaks the file. You uploaded it in (presumably >> FTP's) text mode, which changes \n -> \r\n. But you download it using >> http, which specifies no such conversion in the opposite direction. > > No: I used binary

RMI with Pyro et al

2007-10-10 Thread Sells, Fred
I need a simple client/server architecture with clients on linux and servers on windows. There is no UI in this part, just business rules and access control. Pyro seems pretty cool for this due to it's simplicity. I'm just starting with it and have not been able to get the server side to "see"

Re: howto add a sub-directory to the searchpath / namespace ?

2007-10-10 Thread Larry Bates
stef mientki wrote: > hello, > > my program has become a bit large, > and now I want to split the files over several subdirectories. > So in the example shown below, I just moved the files f1.py and f2.py to > a deeper subdirectory. > > basedirectory\ >mainfile.py >file1.py >file2.py

Re: Problem of Readability of Python

2007-10-10 Thread Bjoern Schliessmann
Kevin wrote: > Am I missing something, or am I the only one who explicitly > declares structs in python? Yes -- you missed my posting :) Regards, Björn -- BOFH excuse #209: Only people with names beginning with 'A' are getting mail this week (a la Microsoft) -- http://mail.python.org/mailm

Re: I'm starting to think like a Pythonista

2007-10-10 Thread brad
Bjoern Schliessmann wrote: > brad wrote: >> low_odds = [1,3,5,7,9] >> # make a list containing 10 - 98 evens only >> big_evens = big_evens = [x for x in list(xrange(99)) if x % 2 == >> 0 and x >8] > > Why use xrange if you convert it to a full list in place? No > advantage there. What is the dis

Re: if then elif

2007-10-10 Thread Larry Bates
Shawn Minisall wrote: > I just learned about if, then elif statements and wrote this program. > The problem is, it's displaying all of the possibilities even after you > enter a 0, or if the fat grams are more then the total number of > calories , that is supposed to stop the program instead of

Re: I'm starting to think like a Pythonista

2007-10-10 Thread Bjoern Schliessmann
brad wrote: > low_odds = [1,3,5,7,9] > # make a list containing 10 - 98 evens only > big_evens = big_evens = [x for x in list(xrange(99)) if x % 2 == > 0 and x >8] Why use xrange if you convert it to a full list in place? No advantage there. Regards, Björn -- BOFH excuse #300: Digital Manipu

Re: for loop question

2007-10-10 Thread Robert Dailey
I've tried everything to make the original CSV module work. It just doesn't. I've tried UTF-16 encoding (which works fine with codecs.open()) but when I pass in the file object returned from codecs.open() into csv.reader(), the call to reader.next() fails because it says something isnt' in the rang

Re: if then elif

2007-10-10 Thread brad
Shawn Minisall wrote: > I just learned about if, then elif statements and wrote this program. > The problem is, it's displaying all of the possibilities even after you > enter a 0, or if the fat grams are more then the total number of > calories , that is supposed to stop the program instead of

Re: for loop question

2007-10-10 Thread Larry Bates
Tim Chase wrote: >> test = u"Hello World" >> >> for cur,next in test: >> print cur,next >> >> Ideally, this would output: >> >> 'H', 'e' >> 'e', 'l' >> 'l', 'l' >> 'l', 'o' >> etc... >> >> Of course, the for loop above isn't valid at all. I am just giving an >> example of what I'm trying to acc

Re: Multidimensional sort

2007-10-10 Thread James Stroud
termiflyer wrote: > How do I sort this: > a > [['3', ['1', '0']], ['4', ['3', '0'], ['2', '0']]] > > where the list can be arbitrarily large by the 3rd dimension (i > think). E.g.: > a > [['3', ['1', '0']], ['4', ['2', '0'], ['3', '0']]] > > > Thanks > Your difficulties come from

Re: for loop question

2007-10-10 Thread George Sakkis
On Oct 10, 4:12 pm, Tim Chase <[EMAIL PROTECTED]> wrote: > > test = u"Hello World" > > > for cur,next in test: > > print cur,next > > > Ideally, this would output: > > > 'H', 'e' > > 'e', 'l' > > 'l', 'l' > > 'l', 'o' > > etc... > > > Of course, the for loop above isn't valid at all. I am just

Re: I'm starting to think like a Pythonista

2007-10-10 Thread Erik Jones
On Oct 10, 2007, at 2:51 PM, brad wrote: > I was looking at a way to implement Ruby's upto method in python. I > came > up with the code below... three years ago, I would never have > thought of > list comprehension, today it seems second nature. This may be totally > un-Pythonic, but I thoug

Re: Multidimensional sort

2007-10-10 Thread Paul Hankin
On Oct 10, 8:47 pm, termiflyer <[EMAIL PROTECTED]> wrote: > How do I sort this: > > >>> a > > [['3', ['1', '0']], ['4', ['3', '0'], ['2', '0']]] > > where the list can be arbitrarily large by the 3rd dimension (i > think). E.g.: > > >>> a > > [['3', ['1', '0']], ['4', ['2', '0'], ['3', '0']]] The

howto add a sub-directory to the searchpath / namespace ?

2007-10-10 Thread stef mientki
hello, my program has become a bit large, and now I want to split the files over several subdirectories. So in the example shown below, I just moved the files f1.py and f2.py to a deeper subdirectory. basedirectory\ mainfile.py file1.py file2.py subdir1\ __init__.py

Re: for loop question

2007-10-10 Thread Tim Chase
Paul Hankin wrote: > On Oct 10, 9:12 pm, Tim Chase <[EMAIL PROTECTED]> wrote: >> >>> pairs = (test[i:i+2] for i in xrange(len(test)-1)) >> >>> for a,b in pairs: >> ... print a,b > > for a, b in zip(test, test[1:]): > print a, b Very nice! I second this solution as better than my original

RE: Launch file from Python

2007-10-10 Thread wang frank
I have tried to use os.system to run an application inside python on ms-window. However, the applicaion will grap the python and I could not do anything inside python shell unless I quit the application. Are there any way to avoid this? so I can still type command in python shell. Here is the c

if then elif

2007-10-10 Thread Shawn Minisall
I just learned about if, then elif statements and wrote this program. The problem is, it's displaying all of the possibilities even after you enter a 0, or if the fat grams are more then the total number of calories , that is supposed to stop the program instead of continuing on with the print

Re: for loop question

2007-10-10 Thread Rafael Sachetto
Very nice solution :) On 10/10/07, Paul Hankin <[EMAIL PROTECTED]> wrote: > > On Oct 10, 9:12 pm, Tim Chase <[EMAIL PROTECTED]> wrote: > > > test = u"Hello World" > > > > > for cur,next in test: > > > print cur,next > > > > > Ideally, this would output: > > > > > 'H', 'e' > > > 'e', 'l' > > >

Re: for loop question

2007-10-10 Thread Robert Dailey
All the ideas presented here are workable. I definitely have a lot of solutions to choose from. Thanks everyone for your help. I wasn't sure if there was some sort of language feature to naturally do this, so I had to post on the mailing list to make sure. -- http://mail.python.org/mailman/listinf

Re: for loop question

2007-10-10 Thread Paul Hankin
On Oct 10, 9:12 pm, Tim Chase <[EMAIL PROTECTED]> wrote: > > test = u"Hello World" > > > for cur,next in test: > > print cur,next > > > Ideally, this would output: > > > 'H', 'e' > > 'e', 'l' > > 'l', 'l' > > 'l', 'o' > > etc... > > > Of course, the for loop above isn't valid at all. I am just

SVN and Setuptools

2007-10-10 Thread percious
I have been thinking a lot about versioning and release of software and I was wondering if what I came up with exists. What I would like to do is create a daemon that sits and checks an SVN repository for tags. When it finds a new tag, it would create an egg for that tag and upload it to an ftp s

Re: for loop question

2007-10-10 Thread Carsten Haese
On Wed, 2007-10-10 at 14:56 -0500, Robert Dailey wrote: > Hi, > > I'm currently writing my own CSV parser since the built in one doesn't > support Unicode. Why do you think you need a CSV parser that supports unicode? -- Carsten Haese http://informixdb.sourceforge.net -- http://mail.python.o

Re: for loop question

2007-10-10 Thread Tim Chase
> test = u"Hello World" > > for cur,next in test: > print cur,next > > Ideally, this would output: > > 'H', 'e' > 'e', 'l' > 'l', 'l' > 'l', 'o' > etc... > > Of course, the for loop above isn't valid at all. I am just giving an > example of what I'm trying to accomplish. Anyone know how I c

Re: for loop question

2007-10-10 Thread Rafael Sachetto
Try this: test = u"Hello World" n = range(len(test)) for i in n: cur = test[i] try: next = test[i+1] except: next = "" print cur, next just On 10/10/07, Robert Dailey <[EMAIL PROTECTED]> wrote: > > Hi, > > I'm currently writing my own CSV parser since the built in on

for loop question

2007-10-10 Thread Robert Dailey
Hi, I'm currently writing my own CSV parser since the built in one doesn't support Unicode. I'm wondering if there's a way to iterate over the characters in a unicode string and have access to both the 'current' and the 'next' characters each iteration. For example: test = u"Hello World" for cur

I'm starting to think like a Pythonista

2007-10-10 Thread brad
I was looking at a way to implement Ruby's upto method in python. I came up with the code below... three years ago, I would never have thought of list comprehension, today it seems second nature. This may be totally un-Pythonic, but I thought it was kind of clever. Man, for some reason, I feel

Multidimensional sort

2007-10-10 Thread termiflyer
How do I sort this: >>> a [['3', ['1', '0']], ['4', ['3', '0'], ['2', '0']]] where the list can be arbitrarily large by the 3rd dimension (i think). E.g.: >>> a [['3', ['1', '0']], ['4', ['2', '0'], ['3', '0']]] Thanks -- http://mail.python.org/mailman/listinfo/python-list

Re: How can Python print the value of an attribute but complain it does not exist?

2007-10-10 Thread Karen Tracey
On 10/10/07, Emre Sevinc <[EMAIL PROTECTED]> wrote: [snip] $ python generatefeedvector-debug.py > Signal vs. Noise > Traceback (most recent call last): > File "generatefeedvector-debug.py", line 37, in ? > title = getwordcounts(feedurl) > File "generatefeedvector-debug.py ", line 21, in ge

Re: How can Python print the value of an attribute but complain it does not exist?

2007-10-10 Thread Dan
On Oct 10, 3:03 pm, Emre Sevinc <[EMAIL PROTECTED]> wrote: > Hello, > > I'm a Python newbie and I'm having a strange trouble with the > following code: > > generatefeedvector-debug.py > === > import feedparser > import re > > def getwordc

Re: The Modernization of Emacs: terminology buffer and keybinding

2007-10-10 Thread Ken Tilton
[EMAIL PROTECTED] wrote: > On Oct 8, 7:32 am, Joost Kremers <[EMAIL PROTECTED]> wrote: > >>[EMAIL PROTECTED] wrote: >> >>>Don't both "man" and those words for measurement come ultimately from >>>words for "hand" (similarly to words like "manual", as in labor)? >> >>no. > > > Do not bluntly con

Re: Pythonic way for handling file errors

2007-10-10 Thread Paul Hankin
On Oct 10, 7:41 pm, wink <[EMAIL PROTECTED]> wrote: > I would like to know what would be considered the most > Pythonic way of handling errors when dealing with files, > solutions that seem reasonable using 2.5: The best way to handle errors is to catch the exceptions that are raised by the code t

Re: Plugins / Modularity

2007-10-10 Thread [EMAIL PROTECTED]
On Oct 10, 12:43 pm, Robin Kåveland <[EMAIL PROTECTED]> wrote: > On Oct 10, 8:38 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> > wrote: > > > > > On Oct 10, 12:30 pm, Robin Kåveland <[EMAIL PROTECTED]> wrote: > > > > Hi there. I'm basically in the process of writing my first substantial > > > applica

Re: Yet another comparison of Python Web Frameworks

2007-10-10 Thread Kay Schluehr
On Oct 10, 8:15 pm, Peter Otten <[EMAIL PROTECTED]> wrote: > Kay Schluehr wrote: > >>http://mdp.cti.depaul.edu/examples > > > The delivered sourcecode is syntactically broken. Tabs and whitespaces > > were mixed and when I open a file like gluon/global.py I find sections > > like this: > > > class

Re: matching a street address with regular expressions

2007-10-10 Thread Karthik Gurusamy
On Oct 10, 10:02 am, "Shawn Milochik" <[EMAIL PROTECTED]> wrote: > On 10/4/07, Ricardo Aráoz <[EMAIL PROTECTED]> wrote: > > > > > Christopher Spears wrote: > > > One of the exercises in Core Python Programming is to > > > create a regular expression that will match a street > > > address. Here is

Re: why did MIT drop scheme for python in intro to computing?

2007-10-10 Thread Grant Edwards
On 2007-10-10, Ashish Hanwadikar <[EMAIL PROTECTED]> wrote: >> However, Tk has been largely abandoned in favor of a native >> GTK+ binding >> >> http://www.stklos.org/ > > I couldn't find any documentation on stklos (other than a few > examples) regarding its gtk+ binding. Could you please point

  1   2   3   >