Re: python ide for ubuntu

2010-08-12 Thread Werner Thie
Eclipse with pydev (great debugging) does the trick nicely, free of charge and throws in some other goodies (JScript/HTML/XML editing) too. I use the EE for Java developer version http://www.eclipse.org/downloads/packages/eclipse-ide-java-ee-developers/heliosr Install pydev from Menu Help/Soft

Re: Why is python not written in C++ ?

2010-08-12 Thread Ulrich Eckhardt
sturlamolden wrote: > On 11 Aug, 08:40, Ulrich Eckhardt wrote: > Header (definition) and source (implementation) is not the same. I'm aware of this and that's not the thing I was talking about. Uli -- Sator Laser GmbH Geschäftsführer: Thorsten Föcking, Amtsgericht Hamburg HR B62 932 -- http

Re: Beyond the moratorium

2010-08-12 Thread Stefan Behnel
Vito 'ZeD' De Tullio, 12.08.2010 08:49: I know, maybe I'm just lazily speculating, but I'm curious about what's next, in python, when GvR will stop the moratorium and will let changes in the language. I don't know what to expect... some syntax sugar about concurrent programming? static types? an

Re: Beyond the moratorium

2010-08-12 Thread Ben Finney
Vito 'ZeD' De Tullio writes: > I know, maybe I'm just lazily speculating, but I'm curious about > what's next, in python, when GvR will stop the moratorium and will let > changes in the language. Subscribe to the ‘python-ideas’ forum for the latest pie-in-the-sky discussions about how to change

Re: Why can't I set sys.ps1 to a unicode string?

2010-08-12 Thread Martin v. Loewis
> So... why does having a non-ascii character in sys.ps1 make the prompt > vanish? I can't pinpoint it to a specific line of code. Most likely, it tries to encode the prompt as ASCII before writing it to stdout. That fails, and it silently ignores the error. FWIW, this is fixed in Python 3. Reg

Re: looping through possible combinations of McNuggets packs of 6,9 and 20

2010-08-12 Thread News123
Hi Steven, On 08/12/2010 01:37 AM, Steven D'Aprano wrote: > On Wed, 11 Aug 2010 13:14:35 -0700, Baba wrote: > >> level: beginner >> >> exercise: given that packs of McNuggets can only be bought in 6, 9 or 20 >> packs, write an exhaustive search to find the largest number of >> McNuggets that cann

Re: how to save a whole web page with something block

2010-08-12 Thread Lawrence D'Oliveiro
In message , Daniel Fetchinson wrote: > A web server may present different output depending on the client > used. It may also require execution of some JavaScript to insert HTML content. > So you might want to make urllib appear as a browser by sending the > appropriate headers. If the above i

Re: looping through possible combinations of McNuggets packs of 6,9 and 20

2010-08-12 Thread MRAB
Steven D'Aprano wrote: On Wed, 11 Aug 2010 13:14:35 -0700, Baba wrote: level: beginner exercise: given that packs of McNuggets can only be bought in 6, 9 or 20 packs, write an exhaustive search to find the largest number of McNuggets that cannot be bought in exact quantity. Is this a trick q

Re: python ide for ubuntu

2010-08-12 Thread geremy condra
On Wed, Aug 11, 2010 at 11:53 PM, Werner Thie wrote: > Eclipse with pydev (great debugging) does the trick nicely, free of charge > and throws in some other goodies (JScript/HTML/XML editing) too. > > I use the EE for Java developer version > > http://www.eclipse.org/downloads/packages/eclipse-ide

Re: looping through possible combinations of McNuggets packs of 6,9 and 20

2010-08-12 Thread News123
On 08/11/2010 10:14 PM, Baba wrote: > level: beginner > > exercise: given that packs of McNuggets can only be bought in 6, 9 or > 20 packs, write an exhaustive search to find the largest number of > McNuggets that cannot be bought in exact quantity. > > exercise source: > http://ocw.mit.edu/cours

Re: Python Tkinter Simple Qn

2010-08-12 Thread Eric Brunel
In article , ChrisChia wrote: > Hi i have the following problem with Python Tkinter. > I switch to switch the image background (which i used Tkinter.Label > with image arg to display on the GUI). > > How can I do that? the callback function which i have created doesn't > seem to work... It is

Re: most popular gui framework for python

2010-08-12 Thread meitham
On Aug 11, 8:31 pm, Back9 wrote: > Hi, > > Does anyone know of what is the most popular gui framework for python > application? > > TIA I used to prefer using GTK mainly because it is available on most platforms. I have realised the majority of the enterprises prefer to use browsers even for loca

Does anyone use Quixote for web developing?

2010-08-12 Thread ph4nut
Hi all,I am learning Quixote a few days ago,,,and i have no idea about whether there is any Google Group talking about Quixote,so i post this post to check that is Quixote been talking in this group before or can i ask question about Quixote here! -- http://mail.python.org/mailman/listinfo/python-

Re: looping through possible combinations of McNuggets packs of 6, 9 and 20

2010-08-12 Thread Jean-Michel Pichavant
Baba wrote: level: beginner exercise: given that packs of McNuggets can only be bought in 6, 9 or 20 packs, write an exhaustive search to find the largest number of McNuggets that cannot be bought in exact quantity. exercise source: http://ocw.mit.edu/courses/electrical-engineering-and-computer

Re: looping through possible combinations of McNuggets packs of 6, 9 and 20

2010-08-12 Thread Paul Rubin
Baba writes: > exercise: given that packs of McNuggets can only be bought in 6, 9 or > 20 packs, write an exhaustive search to find the largest number of > McNuggets that cannot be bought in exact quantity. Is that a homework problem? Hint: first convince yourself that a largest number actually

Re: Does anyone use Quixote for web developing?

2010-08-12 Thread Bruno Desthuilliers
ph4nut a écrit : Hi all,I am learning Quixote a few days ago,,,and i have no idea about whether there is any Google Group talking about Quixote,so i post this post to check that is Quixote been talking in this group before or can i ask question about Quixote here! From the project's home page:

Re: python ide for ubuntu

2010-08-12 Thread Bruno Desthuilliers
geremy condra a écrit : (about eclipse+pydev) Or you could use a text editor and a terminal and spare yourself the agony of dealing with 600MB of Java of questionable quality ;). +1 QOTW -- http://mail.python.org/mailman/listinfo/python-list

Re: cx_Oracle 5.0.4 + Python 3.1.2 + Oracle Instant Client 10.2.04; DLL Load failed on import (Win/NT)

2010-08-12 Thread Alexander Gattin
Hello, On Wed, Aug 11, 2010 at 02:29:24PM -0700, tormod wrote: > I've tried countless times to build & install cx_Oracle on Python > 3.1.2, and failed every time, so I'd like to ask someone for help. ... > I've opened the cx_Oracle.pyd with Dependency Walker (http:// > www.dependencywalker.com/) a

Re: python ide for ubuntu

2010-08-12 Thread Roald de Vries
Hi Bhanu, On Aug 12, 2010, at 4:15 AM, Bhanu Kumar wrote: Hi All, Is there any good free python IDE available in Ubuntu? See a similar discussion at django-users mailing list: http://groups.google.com/group/django-users/browse_thread/thread/562189578285211 Cheers, Roald -- http://mail.python

Re: looping through possible combinations of McNuggets packs of 6, 9 and 20

2010-08-12 Thread Roald de Vries
On Aug 12, 2010, at 11:33 AM, Paul Rubin wrote: Baba writes: exercise: given that packs of McNuggets can only be bought in 6, 9 or 20 packs, write an exhaustive search to find the largest number of McNuggets that cannot be bought in exact quantity. Is that a homework problem? Hint: first con

Programming Puzzles? What's your favorite puzzle?

2010-08-12 Thread Matty Sarro
Hey All! Hope your thursday is treating you well. I'm looking for suggestions on books of programming/engineering puzzles that range from beginners to advanced and even expert level problems. I know they exist; we had them back in college for practicing before the ACM programming competitions. Howe

Copying a file with a question mark in it's name in Windows

2010-08-12 Thread drodrig
A python script I use to backup files on a Windows 2003 server occasionally fails to retrieve the size of a file with a question mark in the name. The exception I get is "OSError #123 The filename, directory name, or volume label syntax is incorrect". I realize that technically a question mark in t

Long rant about Python in Education

2010-08-12 Thread ???????
This is in response to one of the pyWiki pages: PythonAsAFirstLanguage. If there's a better place I could have posted this, please tell me about it. I will be posting this elsewhere over the next few ideas, because I feel it's my duty to spread this idea. It's not grandiose, just Quixotic. Someo

Re: Copying a file with a question mark in it's name in Windows

2010-08-12 Thread Tim Golden
On 12/08/2010 12:49, drodrig wrote: A python script I use to backup files on a Windows 2003 server occasionally fails to retrieve the size of a file with a question mark in the name. The exception I get is "OSError #123 The filename, directory name, or volume label syntax is incorrect". I realize

Re: Beyond the moratorium

2010-08-12 Thread John Roth
On Aug 12, 1:22 am, Ben Finney wrote: > Vito 'ZeD' De Tullio writes: > > > I know, maybe I'm just lazily speculating, but I'm curious about > > what's next, in python, when GvR will stop the moratorium and will let > > changes in the language. > > Subscribe to the ‘python-ideas’ forum for the lat

Secure LDAP Configuration

2010-08-12 Thread sajuptpm
I want to create an LDAP database for my company with following settings. Only the ldap user belongs to my company can search and view ldap entries I want to protect ldap user belongs to my company One ldap user can't search and view others details Only allow ldap u

Renaming OS files by file type in python

2010-08-12 Thread blur959
Hi all, I am creating a program that renames all files of the similar file type. But i am stuck at this part. I tried running this code and I got this error:new_name = os.rename(path, newpath) WindowsError: [Error 183] Cannot create a file when that file already exists. Hope you guys could help

Re: Copying a file with a question mark in it's name in Windows

2010-08-12 Thread Aleksey
On 12 авг, 18:49, drodrig wrote: > A python script I use to backup files on a Windows 2003 server > occasionally fails to retrieve the size of a file with a question mark > in the name. The exception I get is "OSError #123 The filename, > directory name, or volume label syntax is incorrect". I rea

Re: looping through possible combinations of McNuggets packs of 6, 9 and 20

2010-08-12 Thread Dave Angel
Roald de Vries wrote: On Aug 12, 2010, at 11:33 AM, Paul Rubin wrote: Baba writes: exercise: given that packs of McNuggets can only be bought in 6, 9 or 20 packs, write an exhaustive search to find the largest number of McNuggets that cannot be bought in exact quantity. Is that a homework

Re: Programming Puzzles? What's your favorite puzzle?

2010-08-12 Thread Dave Angel
Matty Sarro wrote: Hey All! Hope your thursday is treating you well. I'm looking for suggestions on books of programming/engineering puzzles that range from beginners to advanced and even expert level problems. I know they exist; we had them back in college for practicing before the ACM programmi

Re: Long rant about Python in Education

2010-08-12 Thread D'Arcy J.M. Cain
On Thu, 12 Aug 2010 05:05:55 -0700 (PDT) เข้านอน wrote: > have to teach them to enjoy programming, enjoy computers, and develop > their minds in a way that doesn't involve becoming 'Imams' who are > essentially the learned mafia bosses of terrorism. This is the point that I stopped reading your "

Re: How does Python get the value for sys.stdin.encoding?

2010-08-12 Thread Anssi Saari
Benjamin Kaplan writes: > Sys.stdin and stdout are files, just like any other. There's nothing > special about them at compile time. When the interpreter starts, it > checks to see if they are ttys. If they are, then it tries to figure > out the terminal's encoding based on the environment. Just

__class__ of what

2010-08-12 Thread Eric J. Van der Velden
Hello, I have, class C: n=0 def __init__(s): __class__.n+=1 I do >>> C() This is fine. But of what thing I am taking the __class__ of? I can also do @staticmethod def p(): print(__class__.n) >>> C.p() 1 Thanks, Eric J. --

Re: Programming Puzzles? What's your favorite puzzle?

2010-08-12 Thread Neil Cerutti
On 2010-08-12, Dave Angel wrote: > For puzzles: > > http://projecteuler.net ...if you like math problems. > http://www.pythonchallenge.com ...if you like fooling around with PIL, graphics and bytes. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Using elementtree to Create HTML Form / Set "selected"

2010-08-12 Thread Doug
I'm using elementtree to create a form. I would like to set the "selected" attribute. Setting using the usual option.set( "selected" = "" ) gives me Operations how does one make Operations which is what I need. -- http://mail.python.org/mailman/listinfo/python-list

Re: Does anyone use Quixote for web developing?

2010-08-12 Thread ph4nut
On Aug 12, 5:40 pm, Bruno Desthuilliers wrote: > ph4nut a écrit : > > > Hi all,I am learning Quixote a few days ago,,,and i have no idea about > > whether there is any Google Group talking about Quixote,so i post this > > post to check that is Quixote been talking in this group before or can > > i

Re: Does anyone use Quixote for web developing?

2010-08-12 Thread ph4nut
On Aug 12, 5:40 pm, Bruno Desthuilliers wrote: > ph4nut a écrit : > > > Hi all,I am learning Quixote a few days ago,,,and i have no idea about > > whether there is any Google Group talking about Quixote,so i post this > > post to check that is Quixote been talking in this group before or can > > i

Re: __class__ of what

2010-08-12 Thread Jean-Michel Pichavant
Eric J. Van der Velden wrote: Hello, I have, class C: n=0 def __init__(s): __class__.n+=1 Should be class C: n = 0 def __init__(self): self.__class__.n+=1 C.n+=1 # equivalent to this line (I prefer this one, more readable, less refactor-

Re: __class__ of what

2010-08-12 Thread Eric Brunel
In article <72151646-65cb-47bb-bd55-e7eb67577...@z10g2000yqb.googlegroups.com>, "Eric J. Van der Velden" wrote: > Hello, > > I have, > > class C: > n=0 > def __init__(s): > __class__.n+=1 > > > I do > >>> C() > > This is fine. No it's not, at least in Pytho

Re: __class__ of what

2010-08-12 Thread Peter Otten
Eric J. Van der Velden wrote: > I have, > > class C: > n=0 > def __init__(s): > __class__.n+=1 > > > I do C() > > This is fine. But of what thing I am taking the __class__ of? > I can also do > > @staticmethod > def p(): > p

Re: Using elementtree to Create HTML Form / Set "selected"

2010-08-12 Thread Peter Otten
Doug wrote: > I'm using elementtree to create a form. > > I would like to set the "selected" attribute. > > Setting using the usual > option.set( "selected" = "" ) Maybe that should be option.set(selected="selected"). I think and are equivalent. http://www.w3.org/TR/html4/intro/sgmltut.

Re: Using elementtree to Create HTML Form / Set "selected"

2010-08-12 Thread Doug
On Aug 12, 10:47 am, Peter Otten <__pete...@web.de> wrote: > Doug wrote: > > I'm using elementtree to create a form. > > > I would like to set the "selected" attribute. > > > Setting using the usual > >  option.set( "selected" = "" ) > > Maybe that should be option.set(selected="selected"). I think

Re: __class__ of what

2010-08-12 Thread Stefan Schwarzer
Hello Jean-Michel, On 2010-08-12 16:06, Jean-Michel Pichavant wrote: > Eric J. Van der Velden wrote: > Should be > > class C: > n = 0 > def __init__(self): >self.__class__.n+=1 >C.n+=1 # equivalent to this line (I prefer this one, more > readable, less refactor-friendly)

Inserting/Deleting newline(s) in very large text files

2010-08-12 Thread Dlanor Slegov
Hi, I am dealing with very large text files (a few million lines) and would like to check and modify them according to a well defined format. The format requires ONLY ONE NEWLINE (followed by some sort of text) on top of the file and NO NEWLINE in the very end. The input files can be very dive

Announcing: python-ghostscript 0.3

2010-08-12 Thread Hartmut Goebel
Announcing: python-ghostscript 0.3 A Python-Interface to the Ghostscript C-API using ctypes :Copyright: GNU Public License v3 (GPLv3) :Author: Hartmut Goebel :Homepage: http://bitbucket.org/htgoebel/python-ghostscript :Download:

Re: Programming Puzzles? What's your favorite puzzle?

2010-08-12 Thread Ian Kelly
On Thu, Aug 12, 2010 at 5:41 AM, Matty Sarro wrote: > Hey All! > Hope your thursday is treating you well. I'm looking for suggestions on > books of programming/engineering puzzles that range from beginners to > advanced and even expert level problems. I know they exist; we had them back > in colle

Re: Announcing: python-ghostscript 0.3

2010-08-12 Thread Peter Kleiweg
Hartmut Goebel schreef op de 12e dag van de oogstmaand van het jaar 2010: > Here is an example for how to use the high-level interface of > `python-ghostscript`. This implements a very basic ps2pdf-tool:: > > import sys > import ghostscript > > args = [ > "ps2pdf", # actual val

unicode string alteration

2010-08-12 Thread BAvant Garde
HELP!!! I need help with a unicode issue that has me stumped. I must be doing something  wrong because I don't believe this condition would have slipped thru testing. Wherever the string u'\udbff\udc00' occurs u'\U0010fc00' or unichr(1113088) is substituted and the file loses 1 character result

How to parse a sentence using grammars provided by nltk?

2010-08-12 Thread Sohail
Hi, When I define my own production rules for the grammar the code below runs fine. Can anyone tell me how to use the built in grammars of nltk (if there are any)? >>> groucho_grammar = nltk.parse_cfg(""" ... S -> NP VP ... PP -> P NP ... NP -> Det N | Det N PP | 'I' ... VP -> V NP | VP PP ... De

Extract stack from running python program

2010-08-12 Thread Zac Burns
Is there a utility to extract the stacks from a running python program that is hung? Sounds like a long shot but if anyone knows it would be you guys. -- Zachary Burns (407)590-4814 Aim - Zac256FL Production Engineer Zindagi Games -- http://mail.python.org/mailman/listinfo/python-list

Re: Renaming OS files by file type in python

2010-08-12 Thread MRAB
blur959 wrote: Hi all, I am creating a program that renames all files of the similar file type. But i am stuck at this part. I tried running this code and I got this error:new_name = os.rename(path, newpath) WindowsError: [Error 183] Cannot create a file when that file already exists. Hope yo

OptParse and Constant values

2010-08-12 Thread J
How do you use OptParse with constants? Example: usage = 'Usage: %prog [OPTIONS]' parser = OptionParser(usage) parser.add_option('-l','--level', action='store_const', default=LOG_INFO, help='Set the log level to inject into

Re: OptParse and Constant values

2010-08-12 Thread Robert Kern
On 8/12/10 11:19 AM, J wrote: How do you use OptParse with constants? Example: usage = 'Usage: %prog [OPTIONS]' parser = OptionParser(usage) parser.add_option('-l','--level', action='store_const', default=LOG_INFO, he

Re: Long rant about Python in Education

2010-08-12 Thread John Bokma
"D'Arcy J.M. Cain" writes: > On Thu, 12 Aug 2010 05:05:55 -0700 (PDT) > เข้านอน wrote: >> have to teach them to enjoy programming, enjoy computers, and develop >> their minds in a way that doesn't involve becoming 'Imams' who are >> essentially the learned mafia bosses of terrorism. > > This is

Re: unicode string alteration

2010-08-12 Thread MRAB
BAvant Garde wrote: HELP!!! I need help with a unicode issue that has me stumped. I must be doing something wrong because I don't believe this condition would have slipped thru testing. Wherever the string u'\udbff\udc00' occurs u'\U0010fc00' or unichr(1113088) is substituted and the file l

Re: Why can't I set sys.ps1 to a unicode string?

2010-08-12 Thread RG
In article , "Martin v. Loewis" wrote: > > So... why does having a non-ascii character in sys.ps1 make the prompt > > vanish? > > I can't pinpoint it to a specific line of code. Most likely, it tries > to encode the prompt as ASCII before writing it to stdout. That fails, > and it silently ign

inline exception handling in python

2010-08-12 Thread wheres pythonmonks
Hi! I have on a few occasions now wanted to have inline-exception handling, like the inline if/else operator. For example, The following might raise ZeroDivisionError: f = n / d So, I can look before I leap (which is okay): f = float("nan") if d == 0 else n/d; But, what I'd like to be able t

Re: OptParse and Constant values

2010-08-12 Thread J
On Thu, Aug 12, 2010 at 12:41, Robert Kern wrote: > On 8/12/10 11:19 AM, J wrote: >> >> How do you use OptParse with constants? > http://docs.python.org/library/optparse#standard-option-actions > > 'store_const' means that the option is a flag without arguments and stores > the value provided by

Re: inline exception handling in python

2010-08-12 Thread Thomas Jollans
On Thursday 12 August 2010, it occurred to wheres pythonmonks to exclaim: > try: >f = n / d > except: >f = float("nan") A catch-all except clause. Never a good idea. It's not as bad in this case, as there is only one expression, but there are still a couple of other exceptions that have

Re: inline exception handling in python

2010-08-12 Thread wheres pythonmonks
On Thu, Aug 12, 2010 at 2:08 PM, Thomas Jollans wrote: > On Thursday 12 August 2010, it occurred to wheres pythonmonks to exclaim: >> try: >>    f = n / d >> except: >>    f = float("nan") > > A catch-all except clause. Never a good idea. It's not as bad in this case, as > there is only one expres

Re: inline exception handling in python

2010-08-12 Thread wheres pythonmonks
On Thu, Aug 12, 2010 at 2:19 PM, wheres pythonmonks wrote: > On Thu, Aug 12, 2010 at 2:08 PM, Thomas Jollans wrote: >> On Thursday 12 August 2010, it occurred to wheres pythonmonks to exclaim: >>> try: >>>    f = n / d >>> except: >>>    f = float("nan") >> >> A catch-all except clause. Never a g

Re: looping through possible combinations of McNuggets packs of 6,9 and 20

2010-08-12 Thread Baba
Hi News123 Thank You for helping me out. Indeed i am not looking for the code but rather for hints that direct my reasoning as well as hints as to how to write basic programs like this. You have broken down the approach into 2 parts. I have tried to solve part 1 but i'm not quite there yet. Here'

Re: inline exception handling in python

2010-08-12 Thread MRAB
wheres pythonmonks wrote: Hi! I have on a few occasions now wanted to have inline-exception handling, like the inline if/else operator. For example, The following might raise ZeroDivisionError: f = n / d So, I can look before I leap (which is okay): f = float("nan") if d == 0 else n/d; But

Re: inline exception handling in python

2010-08-12 Thread wheres pythonmonks
On Thu, Aug 12, 2010 at 2:42 PM, MRAB wrote: > wheres pythonmonks wrote: >> >> Hi! >> >> I have on a few occasions now wanted to have inline-exception >> handling, like the inline if/else operator. >> >> For example, >> >> The following might raise ZeroDivisionError: >> >> f = n / d >> >> So, I ca

Re: inline exception handling in python

2010-08-12 Thread Thomas Jollans
On Thursday 12 August 2010, it occurred to wheres pythonmonks to exclaim: > [I just hate function call overhead for this.] I think you've got your priorities wrong. If you want to avoid unnecessary overhead, avoid exceptions more than functions. -- http://mail.python.org/mailman/listinfo/python

Re: looping through possible combinations of McNuggets packs of 6,9 and 20

2010-08-12 Thread Brian Victor
Baba wrote: > def can_buy(n_nuggets): [snip] > can_buy(55) > > as you can see i am trying to loop through all combinations of values > bewtween 1 and n_nuggets and when the equation resolves it should > return True, else it should return False. > > I was hoping that when i then call my function and

Re: cx_Oracle 5.0.4 + Python 3.1.2 + Oracle Instant Client 10.2.04; DLL Load failed on import (Win/NT)

2010-08-12 Thread tormod
On Aug 12, 12:30 pm, Alexander Gattin wrote: > Does Windows have anything like > LD_LIBRARY_PATH/SHLIB_PATH? No, isn't that only if I have an actual Oracle client installed (not the instant client)? But great tip, wasn't exactly the solution, but your question triggered me to check the Windows e

Re: looping through possible combinations of McNuggets packs of 6, 9 and 20

2010-08-12 Thread Peter Otten
Baba wrote: > Thank You for helping me out. Indeed i am not looking for the code but > rather for hints that direct my reasoning as well as hints as to how > to write basic programs like this. > > You have broken down the approach into 2 parts. I have tried to solve > part 1 but i'm not quite th

Re: urllib2 does not implement "with" Python 2.6

2010-08-12 Thread Terry Reedy
On 8/12/2010 1:34 AM, John Nagle wrote: Somewhat to my surprise, in Python 2.6, with urllib2.urlopen(url) as fh : doesn't work. It fails with "AttributeError: addinfourl instance has no attribute '__exit__'". I thought that all the file-like objects supported "with" in 2.6. No? This seems

Re: image resize doesn't work

2010-08-12 Thread Aahz
In article , Chris Hare wrote: > >And I see now what I did wrong - thanks for putting up with the questions. Posting that information is useful for any other newbies who might be following along -- Aahz (a...@pythoncraft.com) <*> http://www.pythoncraft.com/ "...if I were

Re: Inserting/Deleting newline(s) in very large text files

2010-08-12 Thread Thomas Jollans
On Thursday 12 August 2010, it occurred to Dlanor Slegov to exclaim: > Hi, > > I am dealing with very large text files (a few million lines) and would > like to check and modify them according to a well defined format. The > format requires ONLY ONE NEWLINE (followed by some sort of text) on top o

Re: looping through possible combinations of McNuggets packs of 6,9 and 20

2010-08-12 Thread MRAB
Baba wrote: Hi News123 Thank You for helping me out. Indeed i am not looking for the code but rather for hints that direct my reasoning as well as hints as to how to write basic programs like this. You have broken down the approach into 2 parts. I have tried to solve part 1 but i'm not quite th

Re: exception handling with sqlite db errors

2010-08-12 Thread Aahz
In article <2a47b306-45d1-474a-9f8e-5b71eba62...@p11g2000prf.googlegroups.com>, CM wrote: > >Maybe it's not much of an issue, but I think it would be a shame if >occasional hangs/crashes could be caused by these (rare?) database >conflicts if there is a good approach for avoiding them. I guess I

Re: Line-by-line processing when stdin is not a tty

2010-08-12 Thread Nobody
On Wed, 11 Aug 2010 18:49:26 -0700, RG wrote: > This doesn't explain why "cat | cat" when run interactively outputs > line-by-line (which it does). STDIN to the first cat is a TTY, but the > second one isn't. GNU cat doesn't use stdio, it uses read() and write(), so there isn't any buffering.

Re: Announcing: python-ghostscript 0.3

2010-08-12 Thread Aahz
In article , Peter Kleiweg wrote: >Hartmut Goebel schreef op de 12e dag van de oogstmaand van het jaar 2010: > >> Here is an example for how to use the high-level interface of >> `python-ghostscript`. This implements a very basic ps2pdf-tool:: >> >> import sys >> import ghostscript >> >>

Re: Why can't I set sys.ps1 to a unicode string?

2010-08-12 Thread Thomas Jollans
On Thursday 12 August 2010, it occurred to RG to exclaim: > %%% /&%%% > > If this were a properly unicode-enabled newsreader you would see a > yin-yang symbol in the middle of s2. Are you sure about that? Now maybe the mailing list gateway is messing things up, but I rather suspect your newsread

Re: looping through possible combinations of McNuggets packs of 6, 9 and 20

2010-08-12 Thread Roald de Vries
On Aug 12, 2010, at 9:02 PM, Peter Otten wrote: Baba wrote: Thank You for helping me out. Indeed i am not looking for the code but rather for hints that direct my reasoning as well as hints as to how to write basic programs like this. You have broken down the approach into 2 parts. I have

Re: looping through possible combinations of McNuggets packs of 6,9 and 20

2010-08-12 Thread Martin P. Hellwig
On 08/11/10 21:14, Baba wrote: How about rephrasing that question in your mind first, i.e.: For every number that is one higher then the previous one*: If this number is dividable by: 6 or 9 or 20 or any combination of 6, 9, 20 than this number _can_ be bought in an exac

Re: Announcing: python-ghostscript 0.3

2010-08-12 Thread Peter Kleiweg
Aahz schreef op de 12e dag van de oogstmaand van het jaar 2010: > In article , > Peter Kleiweg wrote: > >Hartmut Goebel schreef op de 12e dag van de oogstmaand van het jaar 2010: > > > >> Here is an example for how to use the high-level interface of > >> `python-ghostscript`. This implements a v

Re: inline exception handling in python

2010-08-12 Thread wheres pythonmonks
On Thu, Aug 12, 2010 at 2:57 PM, Thomas Jollans wrote: > On Thursday 12 August 2010, it occurred to wheres pythonmonks to exclaim: >> [I just hate function call overhead for this.] > > I think you've got your priorities wrong. If you want to avoid unnecessary > overhead, avoid exceptions more than

Decompressing a file retrieved by URL seems too complex

2010-08-12 Thread John Nagle
I'm reading a URL which is a .gz file, and decompressing it. This works, but it seems far too complex. Yet none of the "wrapping" you might expect to work actually does. You can't wrap a GzipFile around an HTTP connection, because GzipFile, reasonably enough, needs random access, and tries t

EXOR or symmetric difference for the Counter class

2010-08-12 Thread Paddy
I find myself needing to calculate the difference between two Counters or multisets or bags. I want those items that are unique to each bag. I know how to calculate it: >>> b = Counter(a=1, b=2) >>> c = Counter(a=3, b=1) >>> diff = (b - c) + (c - b) >>> (b - c) Counter({'b': 1

Re: looping through possible combinations of McNuggets packs of 6, 9 and 20

2010-08-12 Thread News123
Hi Baba, The last tips should really help you getting started: for testing your function you could do: Below your uncorrected code and a test for it def can_buy(n_nuggets): for a in range (1,n_nuggets): for b in range (1,n_nuggets): for c in range (1,n_nuggets):

Re: default behavior

2010-08-12 Thread David Niergarth
Peter Otten <__pete...@web.de> wrote: > > >>> 1 .conjugate() > This is a syntax I never noticed before. My built-in complier (eyes) took one look and said: "that doesn't work." Has this always worked in Python but I never noticed? I see other instance examples also work. >>> '1' .zfill(2) '01

Re: shelf-like list?

2010-08-12 Thread Thomas Jollans
On Tuesday 10 August 2010, it occurred to kj to exclaim: > I'm looking for a module that implements "persistent lists": objects > that behave like lists except that all their elements are stored > on disk. IOW, the equivalent of "shelves", but for lists rather > than a dictionaries. > > Does anyo

Re: looping through possible combinations of McNuggets packs of 6, 9 and 20

2010-08-12 Thread News123
One more small tip to verify whether your code is working: On 08/12/2010 10:28 PM, News123 wrote: > Hi Baba, Your code, but returning the result as suggested in my preious post: > def can_buy(n_nuggets): >for a in range (1,n_nuggets): >for b in range (1,n_nuggets): >for

Re: default behavior

2010-08-12 Thread David Niergarth
[Oops, now complete...] Peter Otten <__pete...@web.de> wrote: > > > >>> 1 .conjugate() > This is a syntax I never noticed before. My built-in complier (eyes) took one look and said: "that doesn't work." Has this always worked in Python but I never noticed? I see other instance examples also work.

Floating numbers

2010-08-12 Thread Bradley Hintze
Hi all. Is there a way I can keep my floating point number as I typed it? For example, I want 34.52 to be 34.52 and NOT 34.520002. -- Bradley J. Hintze Graduate Student Duke University School of Medicine 801-712-8799 -- http://mail.python.org/mailman/listinfo/python-list

Decompressing a file retrieved by URL seems too complex

2010-08-12 Thread John Nagle
(Repost with better indentation) I'm reading a URL which is a .gz file, and decompressing it. This works, but it seems far too complex. Yet none of the "wrapping" you might expect to work actually does. You can't wrap a GzipFile around an HTTP connection, because GzipFile, reasonably enough,

Re: looping through possible combinations of McNuggets packs of 6,9 and 20

2010-08-12 Thread News123
On 08/12/2010 09:56 PM, Martin P. Hellwig wrote: > On 08/11/10 21:14, Baba wrote: > > > How about rephrasing that question in your mind first, i.e.: > > For every number that is one higher then the previous one*: > If this number is dividable by: > 6 or 9 or 20 or any combination of

Re: looping through possible combinations of McNuggets packs of 6, 9 and 20

2010-08-12 Thread John Posner
On 8/12/2010 9:22 AM, Dave Angel wrote: Now you have to find the largest number below 120, which you can easily do with brute force Dept of overkill, iterators/generators division ... -John #-- from itertools import imap, product, ifilter from operator import mul box_sizes =

Re: default behavior

2010-08-12 Thread Peter Otten
David Niergarth wrote: > [Oops, now complete...] > Peter Otten <__pete...@web.de> wrote: >> >> > >>> 1 .conjugate() >> > This is a syntax I never noticed before. My built-in complier (eyes) > took one look and said: "that doesn't work." (1).conjugate may hurt a little less. Anyway, the space is

re.sub and variables

2010-08-12 Thread fuglyducky
I have a function that I am attempting to call from another file. I am attempting to replace a string using re.sub with another string. The problem is that the second string is a variable. When I get the output, it shows the variable name rather than the value. Is there any way to pass a variable i

Re: Floating numbers

2010-08-12 Thread Gary Herron
On 08/12/2010 01:43 PM, Bradley Hintze wrote: Hi all. Is there a way I can keep my floating point number as I typed it? For example, I want 34.52 to be 34.52 and NOT 34.520002. Is this a Python question? The answer is both Yes and No. The binary floating point representation of nu

Re: Floating numbers

2010-08-12 Thread Grant Edwards
On 2010-08-12, Bradley Hintze wrote: > Is there a way I can keep my floating point number as I typed it? No. > For example, I want 34.52 to be 34.52 and NOT 34.520002. You can't represent 34.52 using base-2 IEEE floating point (the HW floating point format used by pretty much all modern co

Re: Floating numbers

2010-08-12 Thread Grant Edwards
On 2010-08-12, Grant Edwards wrote: > On 2010-08-12, Bradley Hintze wrote: > >> Is there a way I can keep my floating point number as I typed it? > > No. > >> For example, I want 34.52 to be 34.52 and NOT 34.520002. > > You can't represent 34.52 using base-2 IEEE floating point (the HW > floa

Re: Floating numbers

2010-08-12 Thread Philip Semanchuk
On Aug 12, 2010, at 4:43 PM, Bradley Hintze wrote: Hi all. Is there a way I can keep my floating point number as I typed it? For example, I want 34.52 to be 34.52 and NOT 34.520002. Hi Bradley, Use the Decimal type instead. It's not as convenient as float, but it will give you a consis

Re: Floating numbers

2010-08-12 Thread Thomas Jollans
On Thursday 12 August 2010, it occurred to Bradley Hintze to exclaim: > Hi all. > > Is there a way I can keep my floating point number as I typed it? For > example, I want 34.52 to be 34.52 and NOT 34.520002. The conversion from decimal to binary and vice versa is inexact -- but they're the

Re: Floating numbers

2010-08-12 Thread Chris Rebert
On Thu, Aug 12, 2010 at 1:43 PM, Bradley Hintze wrote: > Hi all. > > Is there a way I can keep my floating point number as I typed it? For > example, I want 34.52 to be 34.52 and NOT 34.520002. See also: http://en.wikipedia.org/wiki/Floating_point#Representable_numbers.2C_conversion_and_ro

Re: Floating numbers

2010-08-12 Thread Grant Edwards
On 2010-08-12, Grant Edwards wrote: >> Here are the nitty-gritty details: >> >> http://docs.sun.com/source/806-3568/ncg_goldberg.html > > Here is a gentler intro: > > http://pyfaq.infogami.com/why-are-floating-point-calculations-so-inaccurate And another good page: http://docs.python.org/t

  1   2   >