Re: Advice on how to get started with 2D-plotting ?

2011-09-06 Thread CM
> Now, for my work, I would need to learn the basics fast, for a one-time > quick-n-dirty job. > > This involves a graphic comparison of RFC1918 IP subnets allocation across > several networks. > > The idea is to draw parallel lines, with segments (subnets) coloured green, > yellow or red depending

Re: Representation of floats (-> Mark Dickinson?)

2011-09-06 Thread jmfauth
On 7 sep, 05:58, casevh wrote: > ... > > Also note that 1.1 * 1.1 is not the same as 1.21. > > >>> (1.1 * 1.1).as_integer_ratio() > > (5449355549118301, 4503599627370496)>>> (1.21).as_integer_ratio() > > (1362338887279575, 1125899906842624) > > This doesn't explain why 2.7.2 displayed a differen

Re: Advice on how to get started with 2D-plotting ?

2011-09-06 Thread CM
On Sep 6, 2:27 pm, Fred Pacquier wrote: > Hi, > > I'm a Python long-timer, but I've never had to use tools like Matplotlib & > others before. > > Now, for my work, I would need to learn the basics fast, for a one-time > quick-n-dirty job. > > This involves a graphic comparison of RFC1918 IP subnet

Re: strange thing:

2011-09-06 Thread W. eWatson
On 9/6/2011 7:48 PM, Chris Angelico wrote: On Wed, Sep 7, 2011 at 12:43 PM, W. eWatson wrote: CA, Did you respond to my off-NG msg about FORTRAN? Perhaps it's caught in my spam on the net. No, I didn't; as someone else pointed out, you'll get better results asking on a dedicated Fortran list.

Re: Floating point multiplication in python

2011-09-06 Thread Steven D'Aprano
On Wed, 7 Sep 2011 02:07 am Thomas 'PointedEars' Lahn wrote: > Thomas Rachel wrote: > >> Now if you multiply two values with an error, the error also propagates >> into the result - PLUs the result can have its own error source - in the >> same order of magnitude. >> >> (a+e) * (a+e) = a*a + 2*a

Re: sqlite3 with context manager

2011-09-06 Thread Tim Arnold
On 9/3/2011 3:03 AM, Carl Banks wrote: On Friday, September 2, 2011 11:43:53 AM UTC-7, Tim Arnold wrote: Hi, I'm using the 'with' context manager for a sqlite3 connection: with sqlite3.connect(my.database,timeout=10) as conn: conn.execute('update config_build set datetime=?,result

Re: Representation of floats (-> Mark Dickinson?)

2011-09-06 Thread casevh
On Sep 6, 6:37 am, jmfauth wrote: > This is just an attempt to put > thehttp://groups.google.com/group/comp.lang.python/browse_thread/thread/... > discussion at a correct level. > > With Python 2.7 a new float number representation (the David Gay's > algorithm) > has been introduced. If this is w

Re: import os or import os.path

2011-09-06 Thread Joe Riopel
On Tue, Sep 6, 2011 at 5:25 PM, Jabba Laci wrote: > Hi, > > If I want to use the 'os.path' module, it's enought to import 'os': > > import os > if os.path.isfile('/usr/bin/bash'): >    print 'got it' > > In other source codes I noticed that people write 'import os.path' in > this case. Which is be

Re: strange thing:

2011-09-06 Thread Chris Angelico
On Wed, Sep 7, 2011 at 12:43 PM, W. eWatson wrote: > CA, Did you respond to my off-NG msg about FORTRAN? Perhaps it's caught in > my spam on the net. No, I didn't; as someone else pointed out, you'll get better results asking on a dedicated Fortran list. ChrisA -- http://mail.python.org/mailman

Re: strange thing:

2011-09-06 Thread W. eWatson
CA, Did you respond to my off-NG msg about FORTRAN? Perhaps it's caught in my spam on the net. -- http://mail.python.org/mailman/listinfo/python-list

Looking for open-source Python projects to help out with

2011-09-06 Thread Littlefield, Tyler
Hello: I've got a bit of time on my hands, so I'm curious what sorts of projects there are that people needs help with. I'd like to choose something that doesn't have a ton of red tape, but is stable, which is why I ask here instead of just Googling open source projects. My main interests lie

Re: PEP 20 - Silly Question?

2011-09-06 Thread Joshua Miller
You sure it wasn't the invisible one? you know the one in the white text that blends into the background? On Tue, Sep 6, 2011 at 9:25 PM, MRAB wrote: > On 07/09/2011 01:36, Ben Finney wrote: >> >> Zero Piraeus  writes: >> >>> On 6 September 2011 12:17, Joseph Armbruster >>>  wrote: I no

Re: PEP 20 - Silly Question?

2011-09-06 Thread MRAB
On 07/09/2011 01:36, Ben Finney wrote: Zero Piraeus writes: On 6 September 2011 12:17, Joseph Armbruster wrote: I noticed that it says only 19 of 20 have been written down. Which one was not written down? The last one. I always thought it was the first one. Or the 6.25th one, I forget.

Re: import os or import os.path

2011-09-06 Thread Mark Hammond
On 7/09/2011 7:47 AM, Ian Kelly wrote: On Tue, Sep 6, 2011 at 3:25 PM, Jabba Laci wrote: Hi, If I want to use the 'os.path' module, it's enought to import 'os': import os if os.path.isfile('/usr/bin/bash'): print 'got it' In other source codes I noticed that people write 'import os.path'

Re: Can't use subprocess.Popen() after os.chroot() - why?

2011-09-06 Thread Nobody
On Sun, 04 Sep 2011 07:22:07 -0700, Erik wrote: > I'm trying to do the following: > os.chroot("/tmp/my_chroot") > p = Popen("/bin/date", stdin=PIPE, stdout=PIPE, stderr=PIPE) > but the Popen call is dying with the following exception: > LookupError: unknown encoding: string-escape > > Am I mi

Re: PEP 20 - Silly Question?

2011-09-06 Thread Ben Finney
Zero Piraeus writes: > On 6 September 2011 12:17, Joseph Armbruster > wrote: > > I noticed that it says only 19 of 20 have been written down.  Which > > one was not written down? > > The last one. I always thought it was the first one. Or the 6.25th one, I forget. -- \“When in doubt

Re: Tkinter label height to fit content

2011-09-06 Thread Bart Kastermans
rantingrick writes: > On Sep 6, 5:00 pm, Bart Kastermans wrote: >> rantingrick writes: >> > Hmm, i can replace all that code with this... >> >> Because I stupidly forgot to repeat the original problem I had, and my >> code doesn't show it (and doesn't show the correct use of the function I >> w

Re: Tkinter label height to fit content

2011-09-06 Thread rantingrick
On Sep 6, 5:40 pm, rantingrick wrote: > On Sep 6, 5:00 pm, Bart Kastermans wrote: > Take your input data and replace ALL single newlines with null strings CORRECTION: Take your input data and replace ALL single newlines with A SINGLE SPACE -- http://mail.python.org/mailman/listinfo/python-list

Re: Tkinter label height to fit content

2011-09-06 Thread rantingrick
On Sep 6, 5:00 pm, Bart Kastermans wrote: > rantingrick writes: > > Hmm, i can replace all that code with this... > > Because I stupidly forgot to repeat the original problem I had, and my > code doesn't show it (and doesn't show the correct use of the function I > wrote). Oh NOW i see! This new

Re: MIMEText encode error - Python 2.6.6

2011-09-06 Thread MRAB
On 06/09/2011 22:52, neubyr wrote: I am trying to write a program which can email file's content using smtplib. I am getting following error while using Python 2.6.6 version. {{{ File "./killed_jobs.py", line 88, in sendmail msg = MIMEText(ipfile.read, 'plain') File "/home/ssp/sge/python/2

Re: Advice on how to get started with 2D-plotting ?

2011-09-06 Thread rantingrick
On Sep 6, 1:27 pm, Fred Pacquier wrote: > I'm a Python long-timer, but I've never had to use tools like Matplotlib & > others before. > > Now, for my work, I would need to learn the basics fast, for a one-time > quick-n-dirty job. ## ## START SCRIPT ## ## # # Easy_

Re: Tkinter label height to fit content

2011-09-06 Thread Bart Kastermans
rantingrick writes: > Hmm, i can replace all that code with this... Because I stupidly forgot to repeat the original problem I had, and my code doesn't show it (and doesn't show the correct use of the function I wrote). The code shows that I now know how to compute the number of lines and item

MIMEText encode error - Python 2.6.6

2011-09-06 Thread neubyr
I am trying to write a program which can email file's content using smtplib. I am getting following error while using Python 2.6.6 version. {{{ File "./killed_jobs.py", line 88, in sendmail msg = MIMEText(ipfile.read, 'plain') File "/home/ssp/sge/python/2.6.6/lib/python2.6/email/mime/text.py",

Re: import os or import os.path

2011-09-06 Thread Ian Kelly
On Tue, Sep 6, 2011 at 3:25 PM, Jabba Laci wrote: > Hi, > > If I want to use the 'os.path' module, it's enought to import 'os': > > import os > if os.path.isfile('/usr/bin/bash'): >    print 'got it' > > In other source codes I noticed that people write 'import os.path' in > this case. Which is be

Re: Tkinter label height to fit content

2011-09-06 Thread rantingrick
Or if you prefer the alternating background approach... ## # Easy_as.py ## import Tkinter as tk from ScrolledText import ScrolledText import tkFont import random END = 'end' INSERT = 'insert' # # Create some puesdo data. data = [ '{0}.{1}'.format(x, 'blah'*rand

import os or import os.path

2011-09-06 Thread Jabba Laci
Hi, If I want to use the 'os.path' module, it's enought to import 'os': import os if os.path.isfile('/usr/bin/bash'): print 'got it' In other source codes I noticed that people write 'import os.path' in this case. Which is better practice? Thanks, Laszlo -- http://mail.python.org/mailman/

Re: Tkinter label height to fit content

2011-09-06 Thread rantingrick
Hmm, i can replace all that code with this... # # Easy_as.py # import Tkinter as tk from ScrolledText import ScrolledText import tkFont import random # Create some puesdo data. data = [ '{0}.{1}'.format(x, 'blah'*random.randint(4, 50)) for x in range(100) ] ##print data # Create the ma

Re: Portable locale usage

2011-09-06 Thread garabik-news-2005-05
Thomas Jollans wrote: > It looks like you don't actually care about the encoding: in your first > example, you use the default system encoding, which you do not control, > and in your second example, you're using two different encodings on the > two platforms. So why do you care whether or not t

Re: Relative seeks on string IO

2011-09-06 Thread Terry Reedy
On 9/6/2011 3:18 AM, Pierre Quentel wrote: I am wondering why relative seeks fail on string IO in Python 3.2 Good question. from io import StringIO txt = StringIO('Favourite Worst Nightmare') txt.seek(8) # no problem with absolute seek Please post code without non-code inden

Re: Tkinter label height to fit content

2011-09-06 Thread Bart Kastermans
I build on the suggestion by rantingrick, but took it in a bit different direction. I now have working code that performs reasonable. The reason for the class lines (as opposed to just a function) is b/c font.measure appears not that fast. So I want to remember between different calls to lines.

Re: Installing WebDAV server

2011-09-06 Thread Fokke Nauta
"Dennis Lee Bieber" wrote in message news:mailman.809.1315328739.27778.python-l...@python.org... > On Tue, 6 Sep 2011 16:46:17 +0200, "Fokke Nauta" > declaimed the following in > gmane.comp.python.general: > > >> --- >> Python 2.7.2 (default, Jun 12 2011,

Advice on how to get started with 2D-plotting ?

2011-09-06 Thread Fred Pacquier
Hi, I'm a Python long-timer, but I've never had to use tools like Matplotlib & others before. Now, for my work, I would need to learn the basics fast, for a one-time quick-n-dirty job. This involves a graphic comparison of RFC1918 IP subnets allocation across several networks. The idea is to

Re: PEP 20 - Silly Question?

2011-09-06 Thread Peter Otten
Joseph Armbruster wrote: > I have used Python for some time and ran a windows build-bot for a bit. > This morning, I told a fellow developer "There should be only one obvious > way to do it." and then I proceeded to forward him to the Zen of Python > and sent him a link to: > http://www.python.or

Re: PEP 20 - Silly Question?

2011-09-06 Thread Zero Piraeus
: On 6 September 2011 12:17, Joseph Armbruster wrote: > I noticed that it says only 19 of 20 have been written down.  Which one was > not written down? The last one. -[]z. -- http://mail.python.org/mailman/listinfo/python-list

Re: PEP 20 - Silly Question?

2011-09-06 Thread Eric Snow
On Tue, Sep 6, 2011 at 10:17 AM, Joseph Armbruster wrote: > I have used Python for some time and ran a windows build-bot for a bit. >  This morning, I told a fellow developer "There should be only one obvious > way to do it." and then I proceeded to forward him to the Zen of Python and > sent him

PEP 20 - Silly Question?

2011-09-06 Thread Joseph Armbruster
I have used Python for some time and ran a windows build-bot for a bit. This morning, I told a fellow developer "There should be only one obvious way to do it." and then I proceeded to forward him to the Zen of Python and sent him a link to: http://www.python.org/dev/peps/pep-0020/ I noticed that

Re: Floating point multiplication in python

2011-09-06 Thread Thomas 'PointedEars' Lahn
Thomas Rachel wrote: > Now if you multiply two values with an error, the error also propagates > into the result - PLUs the result can have its own error source - in the > same order of magnitude. > > (a+e) * (a+e) = a*a + 2*a*e + e*e. So your new error term is 2*a*e + e*e > or (2*a + e) * e. Yo

Re: Portable locale usage

2011-09-06 Thread Thomas Jollans
On 06/09/11 16:46, ssegvic wrote: > For the moment, I only wish to properly sort a Croatian text file > both on Windows and Linux (I am a cautious guy, I like reachable > goals). > When the locale is properly set, sorting works like a charm > with mylist.sort(key=locale.strxfrm). The problem with

Re: Portable locale usage

2011-09-06 Thread ssegvic
On 6 ruj, 15:13, Vlastimil Brom wrote: > There may be some differences btween OSes end the versions, but using > python 2.7 and 3.2 on Win XP and Win7 (Czech) > I get the following results for setlocale: > > >>> locale.setlocale(locale.LC_ALL,'Croatian') > > 'Croatian_Croatia.1250'>>> locale.getl

Re: Python marks an instance of my class undefined

2011-09-06 Thread Hans Mulder
On 6/09/11 16:18:32, Laszlo Nagy wrote: On 2011-09-06 15:42, Kayode Odeyemi wrote: I was able to get this solved by calling class like this: >>> from core.fleet import Fleet >>> f = Fleet() Thanks to a thread from the list titled "TypeError: 'module' object is not callable" Or you can also do

Re: Portable locale usage

2011-09-06 Thread ssegvic
On 6 ruj, 13:16, Thomas Jollans wrote: > > locale.setlocale(locale.LC_ALL, (myISOCountryCode, > > locale.getpreferredencoding())) > > As far as I can tell, this does work. Can you show us a traceback? Sorry, I was imprecise. I wanted to say that the above snippet does not work both on Windows an

Re: Installing WebDAV server

2011-09-06 Thread Fokke Nauta
"becky_lewis" wrote in message news:f5b9ec16-de9a-4365-81a8-860dc27a9...@d25g2000yqh.googlegroups.com... On Sep 5, 3:51 pm, "Fokke Nauta" wrote: > > Hi Becky, > > I tried it straight away: > directory=D:\Webdav\ > directory=D:/Webdav/ > > Didn't work, in both cases the same error "fshandler:get_

Re: Python marks an instance of my class undefined

2011-09-06 Thread Kayode Odeyemi
On Tue, Sep 6, 2011 at 3:18 PM, Laszlo Nagy wrote: > On 2011-09-06 15:42, Kayode Odeyemi wrote: > >> I was able to get this solved by calling class like this: >> >> >>> from core.fleet import Fleet >> >>> f = Fleet() >> >> Thanks to a thread from the list titled "TypeError: 'module' object is not

Re: Python marks an instance of my class undefined

2011-09-06 Thread Laszlo Nagy
On 2011-09-06 15:42, Kayode Odeyemi wrote: I was able to get this solved by calling class like this: >>> from core.fleet import Fleet >>> f = Fleet() Thanks to a thread from the list titled "TypeError: 'module' object is not callable" Or you can also do this: import core.fleet # import modul

Re: Python marks an instance of my class undefined

2011-09-06 Thread Kayode Odeyemi
I was able to get this solved by calling class like this: >>> from core.fleet import Fleet >>> f = Fleet() Thanks to a thread from the list titled "TypeError: 'module' object is not callable" On Tue, Sep 6, 2011 at 2:02 PM, Kayode Odeyemi wrote: > Is there anything I need to do to create an in

Representation of floats (-> Mark Dickinson?)

2011-09-06 Thread jmfauth
This is just an attempt to put the http://groups.google.com/group/comp.lang.python/browse_thread/thread/a008af1ac2968833# discussion at a correct level. With Python 2.7 a new float number representation (the David Gay's algorithm) has been introduced. If this is well honored in Python 2.7, it seem

Re: Portable locale usage

2011-09-06 Thread Vlastimil Brom
2011/9/6 ssegvic : > Hi, > > I am musing on how to write portable Python3 code which would > take advantage of the standard locale module. > > For instance, it would be very nice if we could say something like: > > # does not work! > myISOCountryCode='hr' > locale.setlocale(locale.LC_ALL, (myISOCou

Python marks an instance of my class undefined

2011-09-06 Thread Kayode Odeyemi
Is there anything I need to do to create an instance of a class? I have this simple code(The class is in a package core.fleet): class Fleet(object): def __init__(self): """ no-arg constructor """ def fleet_file_upload(self, filename, type=None): if type == 'user':

HDF5 tree walker

2011-09-06 Thread Alex van der Spek
Is there an equivalent to os.path.walk() for HDF5 file trees accessed through h5py? Thanks! Alex van der Spek -- http://mail.python.org/mailman/listinfo/python-list

Re: Running Python Demo on the Web?

2011-09-06 Thread becky_lewis
On Sep 5, 11:00 pm, Python Fiddle Admin wrote: > Python has been ported to the web browser at pythonfiddle.com. Python > Fiddle can import snippets of code that you are reading on a web page > and run them in the browser. It supports a few popular libraries. > > Another common usage is to post cod

Re: Running Python Demo on the Web?

2011-09-06 Thread Colin J. Williams
On 05-Sep-11 18:00 PM, Python Fiddle Admin wrote: Python has been ported to the web browser at pythonfiddle.com. Python Fiddle can import snippets of code that you are reading on a web page and run them in the browser. It supports a few popular libraries. Another common usage is to post code on

Beginner's query - What is scope of Python for Embedded Programming(C, C++) ?

2011-09-06 Thread Santosh Dumbre
Hi, Please consider a beginner's query - I am 9 -years experienced in C++. Currently working in Automation domain. Will Python help me to work in Automation/Embedded domain ? Your advice is highly appreciated. Please reply. Thanks a lot, Santosh. -- http://mail.python.org/mailman/listinfo/py

Re: Installing WebDAV server

2011-09-06 Thread becky_lewis
On Sep 5, 3:51 pm, "Fokke Nauta" wrote: > > Hi Becky, > > I tried it straight away: > directory=D:\Webdav\ > directory=D:/Webdav/ > > Didn't work, in both cases the same error "fshandler:get_data: \Webdav not > found". > > I have the opinion that my WebDAV installation is at fault. The database is

Re: One line command line filter

2011-09-06 Thread Hans Mulder
On 6/09/11 01:18:37, Steven D'Aprano wrote: Terry Reedy wrote: The doc says "-c Execute the Python code in command. command can be one or more statements separated by newlines," However, I have no idea how to put newlines into a command-line string. I imagine that it depends on the shell you

Re: Portable locale usage

2011-09-06 Thread Thomas Jollans
On 06/09/11 11:59, ssegvic wrote: > Hi, > > I am musing on how to write portable Python3 code which would > take advantage of the standard locale module. > > For instance, it would be very nice if we could say something like: > > # does not work! Doesn't it? > myISOCountryCode='hr' This is a l

Re: Floating point multiplication in python

2011-09-06 Thread Thomas Rachel
Am 06.09.2011 07:57 schrieb xyz: hi all: As we know , 1.1 * 1.1 is 1.21 . But in python ,I got following : 1.1 * 1.1 1.2102 why python get wrong result? Who can tell me where's the 0.0002 from? 1.1 does not fit in a binary floating point number. It is approximate

Portable locale usage

2011-09-06 Thread ssegvic
Hi, I am musing on how to write portable Python3 code which would take advantage of the standard locale module. For instance, it would be very nice if we could say something like: # does not work! myISOCountryCode='hr' locale.setlocale(locale.LC_ALL, (myISOCountryCode, locale.getpreferredencodin

Re: Floating point multiplication in python

2011-09-06 Thread Duncan Booth
Gary Herron wrote: > (But try: >print 1.1*1.1 > and see that the print statement does hide the roundoff error from you.) That varies according to the version of Python you are using. On my system: Python 2.7 (r27:82525, Jul 4 2010, 09:01:59) [MSC v.1500 32 bit (Intel)] on win32 Type "help

Re: strang thing:

2011-09-06 Thread Wolfgang Rohdewald
On Dienstag 06 September 2011, 守株待兔 wrote: > (date,open,high,low,close,vol,adjclose) = (row[0], > row[1], row[2], row[3],row[4], row[5], row[6]) print > row[0], row[1], row[2], row[3],row[4], row[5], row[6] > > > the wrong output is : > file = open(filename,'r') > TypeError: 's

Re: strang thing:

2011-09-06 Thread Chris Angelico
2011/9/6 守株待兔 <1248283...@qq.com>: >     file = open(filename,'r') > when i  add    (date,open,high,low,close,vol,adjclose) = (row[0], row[1], You're assigning to the name "open", which is shadowing the built-in of the same name. The second time through the loop, you're not calling the usual open

Relative seeks on string IO

2011-09-06 Thread Pierre Quentel
Hi, I am wondering why relative seeks fail on string IO in Python 3.2 Example : from io import StringIO txt = StringIO('Favourite Worst Nightmare') txt.seek(8) # no problem with absolute seek but txt.seek(2,1) # 2 characters from current position raises "IOError: Can't do nonz

strang thing:

2011-09-06 Thread 守株待兔
i found stange thing that i can't solve import os import csv for name in os.listdir('/tmp/quote/'): filename='/tmp/quote/'+name file = open(filename,'r') file.readline() for row in csv.reader(file): print row[0], row[1], row[2], row[3],row[4], row[5], r

Re: One line command line filter

2011-09-06 Thread Peter Otten
Jon Redgrave wrote: > It seems unreasonably hard to write simple one-line unix command line > filters in python: > > eg: ls | python -c " print x.upper()" > > to get at sys.stdin or similar needs an import, which makes a > subsequent for-loop illegal. > python -c "import sys; for x in sys.stdin

Re: Floating point multiplication in python

2011-09-06 Thread Steven D'Aprano
On Tue, 6 Sep 2011 03:57 pm xyz wrote: > hi all: > > As we know , 1.1 * 1.1 is 1.21 . > But in python ,I got following : > 1.1 * 1.1 > 1.2102 The problem is that 1.1 is a *decimal* number, but computers use *binary*, and it is impossible to express 1.1 exactly as a binary num

Re: One line command line filter

2011-09-06 Thread John Wiegley
> Jon Redgrave writes: > It seems unreasonably hard to write simple one-line unix command line > filters in python: > eg: ls | python -c " print x.upper()" [...] > Is there a better solution - if not is this worth a PEP? Have you looked at PyP (http://code.google.com/p/pyp)? John -- htt

Re: Floating point multiplication in python

2011-09-06 Thread Gary Herron
On 09/05/2011 10:57 PM, xyz wrote: hi all: As we know , 1.1 * 1.1 is 1.21 . But in python ,I got following : 1.1 * 1.1 1.2102 why python get wrong result? Who can tell me where's the 0.0002 from? It's not a python errorIt's the nature of floating point arithm