Re: Working with paths

2023-07-16 Thread Kushal Kumaran via Python-list
On Sun, Jul 16 2023 at 03:58:07 PM, Peter Slížik wrote: > Hello, > > I finally had a look at the pathlib module. (Should have done it long ago, > but anyway...). Having in mind the replies from my older thread (File > system path annotations), what is the best way to support all possible path > ty

RE: Working with graphs - Kevin Bacon game - WOT

2019-01-09 Thread Avi Gross
[HUMOR ALERT] Others have given answers that are on topic so mine is not needed. I was amused by the understandable spelling error about doing the unusual variant of a Breath First Search when it is clear they meant Breadth. But it may apply in this case. The Keven Bacon Game is a variation on ca

Re: Working with graphs - Kevin Bacon game

2019-01-09 Thread MRAB
On 2019-01-09 14:09, Josip Skako wrote: I get it now, basically you are accessing class atributes with "self.something", thank You. So now I get this: "['Apollo 13 (1995)', 'Bill Paxton', 'Tom Hanks', 'Kevin Bacon\n', 'Begyndte ombord, Det (1937)', 'Aage Schmidt', 'Valso Holm\n', 'Bersaglio m

Re: Working with graphs - Kevin Bacon game

2019-01-09 Thread Josip Skako
I get it now, basically you are accessing class atributes with "self.something", thank You. So now I get this: "['Apollo 13 (1995)', 'Bill Paxton', 'Tom Hanks', 'Kevin Bacon\n', 'Begyndte ombord, Det (1937)', 'Aage Schmidt', 'Valso Holm\n', 'Bersaglio mobile (1967)', 'Dana Young', 'Bebe Drake\

Re: Working with graphs - Kevin Bacon game

2019-01-09 Thread MRAB
On 2019-01-09 12:46, Josip Skako wrote: Thank You for Your answer, I am not sure what to try anymore, I guess I have to return "ime" from __slots__ at cvor() class to show proper strings and I am not able to do it. With: class cvor: __slots__ = ('ime','susjed') def __repr__(self):

Re: Working with graphs - Kevin Bacon game

2019-01-09 Thread Josip Skako
Thank You for Your answer, I am not sure what to try anymore, I guess I have to return "ime" from __slots__ at cvor() class to show proper strings and I am not able to do it. Now I am not sure that I am going at right direction to do Kevin Bacon game and will I be able to load this data into gr

Re: Working with graphs - Kevin Bacon game

2019-01-09 Thread Josip Skako
Thank You for your answer, I fixed everything as You said. -- https://mail.python.org/mailman/listinfo/python-list

Re: Working with graphs - Kevin Bacon game

2019-01-09 Thread MRAB
On 2019-01-09 09:53, jsk...@gmail.com wrote: I am working on Kevin Bacon game. I have "movies.txt" text file that looks like: Apollo 13 (1995);Bill Paxton;Tom Hanks;Kevin Bacon Begyndte ombord, Det (1937);Aage Schmidt;Valso Holm Bersaglio mobile (1967);Dana Young;Bebe Drake Bezottsovshchina (19

Re: Working with graphs - Kevin Bacon game

2019-01-09 Thread Chris Angelico
On Wed, Jan 9, 2019 at 8:56 PM wrote: > class cvor: > __slots__ = ('ime','susjed') > > My problem is that when I print graph with "print (graph)" I am getting: > > "[<__main__.cvor object at 0x01475275EBE0>, <__main__.cvor object at > 0x01475275EEF0>, <__main__.cvor object at 0x01

Re: Working with dictionaries and keys help please!

2017-06-02 Thread Gregory Ewing
On Thu, 1 Jun 2017 10:29 am, David D wrote: Is there a way of performing this where the key will update so that is continues to work sequentially? It sounds like you don't want a dictionary at all, you want a list. You can use the index() method to find the current "key" of an entry. >>> peop

Re: Working with dictionaries and keys help please!

2017-06-01 Thread Steve D'Aprano
On Thu, 1 Jun 2017 10:29 am, David D wrote: > I have a dictionary with a 10 people, the key being a number (0-10) and the > value being the people's name. I am in the processing of Insert, Adding and > deleting from the dictionary. All seems well until I delete a person and add > a new one. The

Re: Working with dictionaries and keys help please!

2017-05-31 Thread David D
Learning about dictionaries for a database possibly in the future. On Wednesday, May 31, 2017 at 8:58:39 PM UTC-4, MRAB wrote: > On 2017-06-01 01:29, David D wrote: > > I have a dictionary with a 10 people, the key being a number (0-10) and the > > value being the people's name. I am in the proc

Re: Working with dictionaries and keys help please!

2017-05-31 Thread MRAB
On 2017-06-01 01:29, David D wrote: I have a dictionary with a 10 people, the key being a number (0-10) and the value being the people's name. I am in the processing of Insert, Adding and deleting from the dictionary. All seems well until I delete a person and add a new one. The numbers (ke

Re: working with classes, inheritance, _str_ returns and a list

2017-01-15 Thread Frank Millman
"Frank Millman" wrote in message news:o5hnbq$q36$1...@blaine.gmane.org... "Frank Millman" wrote in message news:o5hlh4$1sb$1...@blaine.gmane.org... > > If you are saying - > for item in list: > print(item) > > you can say instead - > for item in list: > print(str(item)) >

Re: working with classes, inheritance, _str_ returns and a list

2017-01-15 Thread Frank Millman
"Frank Millman" wrote in message news:o5hlh4$1sb$1...@blaine.gmane.org... If you are saying - for item in list: print(item) you can say instead - for item in list: print(str(item)) This is not correct, sorry. print(item) will automatically print the string representat

Re: working with classes, inheritance, _str_ returns and a list

2017-01-15 Thread Frank Millman
"David D" wrote in message news:4f0680eb-2678-4ea2-b622-a6cd5a19e...@googlegroups.com... I am creating a parent class and a child class. I am inheriting from the parent with an additional attribute in the child class. I am using __str__ to return the information. When I run > the code, it

Re: working with classes, inheritance, _str_ returns and a list

2017-01-15 Thread Erik
Hi, On 15/01/17 19:58, David D wrote: I am creating a parent class and a child class. I am inheriting from the parent with an additional attribute in the child class. I am using __str__ to return the information. When I run the code, it does exactly what I want, it returns the __str__ informa

Re: working with classes, inheritance, _str_ returns and a list

2017-01-15 Thread Chris Angelico
On Mon, Jan 16, 2017 at 6:58 AM, David D wrote: > I am creating a parent class and a child class. I am inheriting from the > parent with an additional attribute in the child class. I am using __str__ > to return the information. When I run the code, it does exactly what I want, > it returns

Re: Working around multiple files in a folder

2016-12-08 Thread Veek M
Emile van Sebille wrote: > On 11/21/2016 11:27 AM, subhabangal...@gmail.com wrote: >> I have a python script where I am trying to read from a list of files >> in a folder and trying to process something. As I try to take out the >> output I am presently appending to a list. >> >> But I am trying t

Re: Working around multiple files in a folder

2016-11-21 Thread Emile van Sebille
On 11/21/2016 11:27 AM, subhabangal...@gmail.com wrote: I have a python script where I am trying to read from a list of files in a folder and trying to process something. As I try to take out the output I am presently appending to a list. But I am trying to write the result of individual files

Re: working with ctypes and complex data structures

2016-10-06 Thread Michael Felt
On 04-Oct-16 04:48, eryk sun wrote: On Mon, Oct 3, 2016 at 9:27 PM, Michael Felt wrote: int perfstat_subsystem_total( perfstat_id_t *name, perfstat_subsystem_total_t *userbuff, int sizeof_struct, int desired_number); ... +79 class cpu_total: +80 def __init__(self

Re: working with ctypes and complex data structures

2016-10-05 Thread eryk sun
On Wed, Oct 5, 2016 at 9:03 PM, Michael Felt wrote: > >> +80 args = (1, "name", None), (2, "buff", None), (1, "size", >> 0), (1, "count", 1) > > error #1. paramater type 2 (the buffer might be where data is being put, but > for the call, the pointer is INPUT) An output parameter (type 2)

Re: working with ctypes and complex data structures

2016-10-05 Thread Michael Felt
Never said thank you - so, thanks! What I need to do was add the .v at the end so I was accessing the value of the structure. Unlilke Linux, AIX - for reasons unknown to all, they have the time_t definition that is specific to the ABI size, at least for these performance libraries that proba

Re: working with ctypes and complex data structures

2016-10-05 Thread Michael Felt
On 05-Oct-16 22:29, Emile van Sebille wrote: Thanks for the reply! After a shirt coffeebreak - back into the fray - and I found the following: +76 class cpu_total: +77 def __init__(self): +78 __perfstat__ = CDLL("libperfstat.a(shr_64.o)") +79 prototype = CFUNC

Re: working with ctypes and complex data structures

2016-10-05 Thread Emile van Sebille
On 10/05/2016 01:06 PM, Michael Felt wrote: On 02-Oct-16 19:50, Michael Felt wrote: I am trying to understand the documentation re: ctypes and interfacing with existing libraries. I am reading the documentation, and also other sites that have largely just copied the documentation - as well as

Re: working with ctypes and complex data structures

2016-10-05 Thread Michael Felt
On 02-Oct-16 19:50, Michael Felt wrote: I am trying to understand the documentation re: ctypes and interfacing with existing libraries. I am reading the documentation, and also other sites that have largely just copied the documentation - as well as the "free chapter" at O'Reilly (Python Co

Re: working with ctypes and complex data structures

2016-10-03 Thread eryk sun
On Mon, Oct 3, 2016 at 9:27 PM, Michael Felt wrote: > > int perfstat_subsystem_total( >perfstat_id_t *name, >perfstat_subsystem_total_t *userbuff, >int sizeof_struct, >int desired_number); > ... >+79 class cpu_total: >+80 def __init__(self): >+81 __perfst

Re: working with ctypes and complex data structures

2016-10-03 Thread Michael Felt
On 02-Oct-16 19:50, Michael Felt wrote: class perfstat_cpu_total_t(Structure): """ typedef struct { /* global cpu information */ int ncpus;/* number of active logical processors */ int ncpus_cfg; /* number of configured processors */ cha

Re: working with ctypes and complex data structures

2016-10-03 Thread Michael Felt
On 03-Oct-16 16:35, Michael Felt wrote: I'd alias the type instead of defining a struct, e.g. `time_t = c_long`. This preserves automatic conversion of the simple type. The reason for the not using alias is because a) I was trying to be more inline with the text of the include file. I will hav

Re: working with ctypes and complex data structures

2016-10-03 Thread eryk sun
On Mon, Oct 3, 2016 at 2:35 PM, Michael Felt wrote: > On 02-Oct-16 23:44, eryk sun wrote: >> On Sun, Oct 2, 2016 at 5:50 PM, Michael Felt >> wrote: >> >>> b) what I am not understanding - as the basic documentation shows >>> FOO.value as the way to set/get the value of a _field_ >> >> You may b

Re: working with ctypes and complex data structures

2016-10-03 Thread Michael Felt
On 02-Oct-16 23:44, eryk sun wrote: On Sun, Oct 2, 2016 at 5:50 PM, Michael Felt wrote: a) where is documentation on "CField"'s? It's undocumented. So I do not feel so bad about not finding anything :) A CField is a data descriptor that accesses a struct field with the given type, size,

Re: working with ctypes and complex data structures

2016-10-03 Thread Michael Felt
On 02-Oct-16 23:44, eryk sun wrote: On Sun, Oct 2, 2016 at 5:50 PM, Michael Felt wrote: > >a) where is documentation on "CField"'s? I will reply more later - just a quick thanks. Not using maxsize will be good, also in a different patch - also specific to AIX. This "thing" I am working

Re: working with ctypes and complex data structures

2016-10-02 Thread eryk sun
On Sun, Oct 2, 2016 at 5:50 PM, Michael Felt wrote: > > a) where is documentation on "CField"'s? It's undocumented. A CField is a data descriptor that accesses a struct field with the given type, size, and offset. Like most descriptors, it's meant to be accessed as an attribute of an instance, n

Re: working with OpenOffice Calc

2016-07-27 Thread Terry Reedy
On 7/27/2016 1:54 PM, id23...@gmail.com wrote: I am looking for a library that will allow me to work with Calc documents from Python. But so far I was not able to build properly working environment for that. You posted this same question 1 1/2 hours before under a different name. Please don'

Re: working

2016-02-13 Thread Bob Martin
in 753638 20160212 185728 sohcahto...@gmail.com wrote: >On Friday, February 12, 2016 at 1:47:24 AM UTC-8, Mohammed Zakria wrote: >> hello >> i want to know the company that ican work as freelance python devloper > >There are some recruiters that read this mailing list and will send >unsolicited e-

Re: working

2016-02-12 Thread sohcahtoa82
On Friday, February 12, 2016 at 1:47:24 AM UTC-8, Mohammed Zakria wrote: > hello > i want to know the company that ican work as freelance python devloper There are some recruiters that read this mailing list and will send unsolicited e-mail about job openings, but they might pass right over you i

Re: Working with jython in openSUSE 13.2

2015-06-20 Thread Cecil Westerhof
On Saturday 20 Jun 2015 15:01 CEST, Laura Creighton wrote: > In a message of Sat, 20 Jun 2015 12:58:33 +0200, Cecil Westerhof > writes: >> I installed Jython in openSUSE 13.2. But when calling jython I get: >> /usr/bin/build-classpath: error: JAVA_LIBDIR must be set >> Error: Could not find or loa

Re: Working with jython in openSUSE 13.2

2015-06-20 Thread Laura Creighton
In a message of Sat, 20 Jun 2015 12:58:33 +0200, Cecil Westerhof writes: >I installed Jython in openSUSE 13.2. But when calling jython I get: >/usr/bin/build-classpath: error: JAVA_LIBDIR must be set >Error: Could not find or load main class org.python.util.jython > >Does anyone have an ide

Re: Working with Access tables and python scripts

2015-04-14 Thread Mark Lawrence
On 15/04/2015 01:47, Emile van Sebille wrote: On 4/14/2015 3:20 PM, accessnew...@gmail.com wrote: > I have an existing extensive python script that I would like > to modify slightly to run a different variation on a process. > > I also have all the variables I need to run this script (about

Re: Working with Access tables and python scripts

2015-04-14 Thread Emile van Sebille
On 4/14/2015 3:20 PM, accessnew...@gmail.com wrote: > I have an existing extensive python script that I would like > to modify slightly to run a different variation on a process. > > I also have all the variables I need to run this script (about > 20 in total)stored in an Access 2010 64 bit datab

Re: Working with Access tables and python scripts

2015-04-14 Thread hey . ho . fredl
I don't know how to start a Python script from Access, but you could definitely do it the other way around, reading the Access database from Python. An example: --- import pyodbc ODBC_DRIVER = '{Microsoft Access Driver (*.mdb)}' connstr = 'DRIVER={0};DBQ={1}'.format(ODBC_DRIVER, 'filename.mdb')

Re: Working with HTML5 documents

2014-11-20 Thread Ian Kelly
On Thu, Nov 20, 2014 at 1:10 PM, Stefan Behnel wrote: > Ian Kelly schrieb am 20.11.2014 um 20:44: >> On Thu, Nov 20, 2014 at 12:02 PM, Stefan Behnel wrote: >>> There's also the E-factory for creating (sub-)trees and a nicely objectish >>> way: >>> >>> http://lxml.de/lxmlhtml.html#creating-html-wi

Re: Working with HTML5 documents

2014-11-20 Thread Stefan Behnel
Ian Kelly schrieb am 20.11.2014 um 20:44: > On Thu, Nov 20, 2014 at 12:02 PM, Stefan Behnel wrote: >> There's also the E-factory for creating (sub-)trees and a nicely objectish >> way: >> >> http://lxml.de/lxmlhtml.html#creating-html-with-the-e-factory > > That looks ugly with all those caps and

Re: Working with HTML5 documents

2014-11-20 Thread Ian Kelly
On Thu, Nov 20, 2014 at 12:02 PM, Stefan Behnel wrote: > There's also the E-factory for creating (sub-)trees and a nicely objectish > way: > > http://lxml.de/lxmlhtml.html#creating-html-with-the-e-factory That looks ugly with all those caps and also hard to extend. Notably it seems to be missing

Re: Working with HTML5 documents

2014-11-20 Thread Stefan Behnel
Tim schrieb am 20.11.2014 um 18:31: > On Thursday, November 20, 2014 12:04:09 PM UTC-5, Denis McMahon wrote: >>> On Wednesday, November 19, 2014 2:08:27 PM UTC-7, Denis McMahon wrote: So what I'm looking for is a method to create an html5 document using "dom manipulation", ie: d

Re: Working with HTML5 documents

2014-11-20 Thread Tim
On Thursday, November 20, 2014 12:04:09 PM UTC-5, Denis McMahon wrote: > On Wed, 19 Nov 2014 13:43:17 -0800, Novocastrian_Nomad wrote: > > > On Wednesday, November 19, 2014 2:08:27 PM UTC-7, Denis McMahon wrote: > >> So what I'm looking for is a method to create an html5 document using > >> "dom m

Re: Working with HTML5 documents

2014-11-20 Thread Denis McMahon
On Wed, 19 Nov 2014 13:43:17 -0800, Novocastrian_Nomad wrote: > On Wednesday, November 19, 2014 2:08:27 PM UTC-7, Denis McMahon wrote: >> So what I'm looking for is a method to create an html5 document using >> "dom manipulation", ie: >> >> doc = new htmldocument(doctype="HTML") >> html = new htm

Re: Working with HTML5 documents

2014-11-19 Thread Novocastrian_Nomad
On Wednesday, November 19, 2014 2:08:27 PM UTC-7, Denis McMahon wrote: > So what I'm looking for is a method to create an html5 document using "dom > manipulation", ie: > > doc = new htmldocument(doctype="HTML") > html = new html5element("html") > doc.appendChild(html) > head = new html5element("

Re: Working with decimals part 2

2014-08-27 Thread Seymore4Head
On Tue, 26 Aug 2014 10:46:56 +1000, alex23 wrote: >On 26/08/2014 3:55 AM, Seymore4Head wrote: >> I changed the program just a little to give myself a little practice >> with number formats. The main thing I wanted to do was make the >> decimal points line up. The problem I am having is with the

Re: Working with decimals part 2

2014-08-25 Thread alex23
On 26/08/2014 3:55 AM, Seymore4Head wrote: I changed the program just a little to give myself a little practice with number formats. The main thing I wanted to do was make the decimal points line up. The problem I am having is with the print (count)(payment)(balance) line. While I don't want

Re: Working with decimals part 2

2014-08-25 Thread MRAB
On 2014-08-25 18:55, Seymore4Head wrote: import sys import math def row1(number): return str(number).rjust(3) def row2(number): return str(format(number) ',.2f')) That line has to many ')'. The result of 'format' is a string, so there's no need to use 'str'. def row3(number):

Re: Working with decimals part 2

2014-08-25 Thread Mark Lawrence
On 25/08/2014 18:55, Seymore4Head wrote: import sys import math def row1(number): return str(number).rjust(3) def row2(number): return str(format(number) ',.2f')) def row3(number): return '${:.2f}'.format(number) def row4(number): return '$' + str(format(math.floor(number * 10

Re: Working with decimals part 2

2014-08-25 Thread Chris Angelico
On Tue, Aug 26, 2014 at 3:55 AM, Seymore4Head wrote: > For some reason, it is not working. If I try to use row2 I get this > error: > http://i.imgur.com/FgeF9c9.jpg Several meta-issues. Firstly, your subject line talks about 'decimal' again. You're actually working with floats; Python has a qui

Re: Working with decimals

2014-08-24 Thread Chris Angelico
On Mon, Aug 25, 2014 at 12:51 PM, Steven D'Aprano wrote: > Chris Angelico wrote: > >> I love this list. We can go off on a ridiculously long tangent, simply >> because I said that it's only *usually* best to put imports at the top >> of the file. We all agree that it normally is indeed best to hoi

Re: Working with decimals

2014-08-24 Thread Steven D'Aprano
Chris Angelico wrote: > I love this list. We can go off on a ridiculously long tangent, simply > because I said that it's only *usually* best to put imports at the top > of the file. We all agree that it normally is indeed best to hoist > them, and here we are, arguing over measurement methods on

Re: Working with decimals

2014-08-24 Thread Chris Angelico
On Mon, Aug 25, 2014 at 12:16 PM, Steven D'Aprano wrote: > Joshua Landau wrote: > > > python -c "import sys; print('math' in sys.modules)" >> False >> >> An even easier check: >> > python -c "import time; a = time.time(); import math; b = time.time(); > print(b-a)" >> 0.000601291656494

Re: Working with decimals

2014-08-24 Thread Steven D'Aprano
Joshua Landau wrote: python -c "import sys; print('math' in sys.modules)" > False > > An even easier check: > python -c "import time; a = time.time(); import math; b = time.time(); print(b-a)" > 0.0006012916564941406 > python -c "import math, time; a = time.time(); import m

Re: Working with decimals

2014-08-24 Thread Seymore4Head
On Sun, 24 Aug 2014 14:24:19 -0700, Larry Hudson wrote: >On 08/24/2014 08:12 AM, Seymore4Head wrote: >[snip] >> I almost moved, but I was looking at the print out again for this one: >> print('%3d $%-13.2f $%-14.2f' % (count, payment, balance)) >> >> I can't understand why the $%-13.2f is pushed

Re: Working with decimals

2014-08-24 Thread Larry Hudson
On 08/24/2014 08:12 AM, Seymore4Head wrote: [snip] I almost moved, but I was looking at the print out again for this one: print('%3d $%-13.2f $%-14.2f' % (count, payment, balance)) I can't understand why the $%-13.2f is pushed against the first column, but the $%-14.2f is not. It seems like the

Re: Working with decimals

2014-08-24 Thread Joshua Landau
On 24 August 2014 20:40, Ian Kelly wrote: > That's the same check I posted, just using the in operator instead of a > straight lookup and raising an error. I think I need to take a break from the internet. This is the second time in as many threads that I've responded with what I'm commenting on.

Re: Working with decimals

2014-08-24 Thread Ian Kelly
On Sun, Aug 24, 2014 at 1:29 PM, Joshua Landau wrote: > > On 24 August 2014 20:25, Joshua Landau wrote: > > On 24 August 2014 20:19, Ian Kelly wrote: > >> On Sun, Aug 24, 2014 at 1:17 PM, Ian Kelly wrote: > >>> On Sun, Aug 24, 2014 at 1:12 PM, Joshua Landau wrote: > >>> > Is math not already i

Re: Working with decimals

2014-08-24 Thread Ian Kelly
On Sun, Aug 24, 2014 at 1:25 PM, Joshua Landau wrote: > On 24 August 2014 20:19, Ian Kelly wrote: > > On Sun, Aug 24, 2014 at 1:17 PM, Ian Kelly > wrote: > >> > >> On Sun, Aug 24, 2014 at 1:12 PM, Joshua Landau > wrote: > >> > Is math not already imported by start-up? > >> > >> Why would it be

Re: Working with decimals

2014-08-24 Thread Joshua Landau
On 24 August 2014 20:25, Joshua Landau wrote: > On 24 August 2014 20:19, Ian Kelly wrote: >> On Sun, Aug 24, 2014 at 1:17 PM, Ian Kelly wrote: >>> On Sun, Aug 24, 2014 at 1:12 PM, Joshua Landau wrote: >>> > Is math not already imported by start-up? > > I don't mean into the global namespace, bu

Re: Working with decimals

2014-08-24 Thread Joshua Landau
On 24 August 2014 20:19, Ian Kelly wrote: > On Sun, Aug 24, 2014 at 1:17 PM, Ian Kelly wrote: >> >> On Sun, Aug 24, 2014 at 1:12 PM, Joshua Landau wrote: >> > Is math not already imported by start-up? >> >> Why would it be? > > It's easy to check, by the way: > > $ python -c "import sys; print(s

Re: Working with decimals

2014-08-24 Thread Ian Kelly
On Sun, Aug 24, 2014 at 1:17 PM, Ian Kelly wrote: > > On Sun, Aug 24, 2014 at 1:12 PM, Joshua Landau wrote: > > Is math not already imported by start-up? > > Why would it be? It's easy to check, by the way: $ python -c "import sys; print(sys.modules['math'])" Traceback (most recent call last):

Re: Working with decimals

2014-08-24 Thread Ian Kelly
On Sun, Aug 24, 2014 at 1:12 PM, Joshua Landau wrote: > Is math not already imported by start-up? Why would it be? -- https://mail.python.org/mailman/listinfo/python-list

Re: Working with decimals

2014-08-24 Thread Joshua Landau
On 23 August 2014 23:53, Chris Angelico wrote: > On Sun, Aug 24, 2014 at 8:47 AM, Joshua Landau wrote: >> On 23 August 2014 23:31, Chris Angelico wrote: >>> I'd say "never" is too strong (there are times when it's right to put >>> an import inside a function), but yes, in this case it should rea

Re: Working with decimals

2014-08-24 Thread Seymore4Head
On Sun, 24 Aug 2014 00:04:29 -0700, Larry Hudson wrote: >On 08/23/2014 02:13 PM, Seymore4Head wrote: >> On Sat, 23 Aug 2014 13:47:20 -0400, Seymore4Head >> >> I found this function that I will be saving for later. >> def make_it_money(number): >> import math >> return '$' + str(format(m

Re: Working with decimals

2014-08-24 Thread Seymore4Head
On Sun, 24 Aug 2014 00:04:29 -0700, Larry Hudson wrote: >On 08/23/2014 02:13 PM, Seymore4Head wrote: >> On Sat, 23 Aug 2014 13:47:20 -0400, Seymore4Head >> >> I found this function that I will be saving for later. >> def make_it_money(number): >> import math >> return '$' + str(format(m

Re: Working with decimals

2014-08-24 Thread Larry Hudson
On 08/23/2014 02:13 PM, Seymore4Head wrote: On Sat, 23 Aug 2014 13:47:20 -0400, Seymore4Head I found this function that I will be saving for later. def make_it_money(number): import math return '$' + str(format(math.floor(number * 100) / 100, ',.2f')) (I still need more practice to fi

Re: Working with decimals

2014-08-23 Thread Chris Angelico
On Sun, Aug 24, 2014 at 8:47 AM, Joshua Landau wrote: > On 23 August 2014 23:31, Chris Angelico wrote: >> On Sun, Aug 24, 2014 at 7:47 AM, Joshua Landau wrote: >>> So for one "import math" should never go inside a function; you should >>> hoist it to the top of the file with all the other import

Re: Working with decimals

2014-08-23 Thread Joshua Landau
On 23 August 2014 23:31, Chris Angelico wrote: > On Sun, Aug 24, 2014 at 7:47 AM, Joshua Landau wrote: >> So for one "import math" should never go inside a function; you should >> hoist it to the top of the file with all the other imports. > > I'd say "never" is too strong (there are times when i

Re: Working with decimals

2014-08-23 Thread Chris Angelico
On Sun, Aug 24, 2014 at 7:47 AM, Joshua Landau wrote: > So for one "import math" should never go inside a function; you should > hoist it to the top of the file with all the other imports. I'd say "never" is too strong (there are times when it's right to put an import inside a function), but yes,

Re: Working with decimals

2014-08-23 Thread Seymore4Head
On Sat, 23 Aug 2014 22:52:09 +0100, Joshua Landau wrote: >On 23 August 2014 18:47, Seymore4Head wrote: >> Anyone care to suggest what method to use to fix the decimal format? > >It sounds like you want a primer on floating point. The documentation >of the decimal module is actually a good read,

Re: Working with decimals

2014-08-23 Thread Joshua Landau
On 23 August 2014 22:13, Seymore4Head wrote: > def make_it_money(number): > import math > return ' > + str(format(math.floor(number * 100) / 100, ',.2f')) So for one "import math" should never go inside a function; you should hoist it to the top of the file with all the other imports. Yo

Re: Working with decimals

2014-08-23 Thread Joshua Landau
On 23 August 2014 18:47, Seymore4Head wrote: > Anyone care to suggest what method to use to fix the decimal format? It sounds like you want a primer on floating point. The documentation of the decimal module is actually a good read, although I don't doubt there are even better resources somewhere

Re: Working with decimals

2014-08-23 Thread Seymore4Head
On Sat, 23 Aug 2014 13:47:20 -0400, Seymore4Head wrote: >I am trying to do this example: >http://openbookproject.net/pybiblio/practice/wilson/loan.php >The instructions warn that floating point math can get messy so I >cheated a little bit to get me going. > >I made my program work by using numbe

Re: Working with decimals

2014-08-23 Thread Mark Lawrence
On 23/08/2014 20:48, Seymore4Head wrote: Thanks for the links. The python-course looks like a beginner start. It raises one more question. Some have suggested using strings. I understand that strings and numbers are not the same thing. I know that converting numbers to strings can be useful

Re: Working with decimals

2014-08-23 Thread Seymore4Head
On Sat, 23 Aug 2014 20:24:41 +0100, Mark Lawrence wrote: >On 23/08/2014 20:07, Seymore4Head wrote: >> >> Funny, I though using the web would be better than a book. I don't >> think so anymore. Using the web, it is hard to find square one >> tutorial text. >> > >Try typing something like "python

Re: Working with decimals

2014-08-23 Thread Mark Lawrence
On 23/08/2014 20:07, Seymore4Head wrote: Funny, I though using the web would be better than a book. I don't think so anymore. Using the web, it is hard to find square one tutorial text. Try typing something like "python string formatting tutorial" into your favourite search engine and you'

Re: Working with decimals

2014-08-23 Thread Joel Goldstick
On Sat, Aug 23, 2014 at 3:07 PM, Seymore4Head wrote: > On Sat, 23 Aug 2014 14:21:03 -0400, Joel Goldstick > wrote: > >>On Sat, Aug 23, 2014 at 1:47 PM, Seymore4Head >> wrote: >>> I am trying to do this example: >>> http://openbookproject.net/pybiblio/practice/wilson/loan.php >>> The instructions

Re: Working with decimals

2014-08-23 Thread Seymore4Head
On Sat, 23 Aug 2014 14:21:03 -0400, Joel Goldstick wrote: >On Sat, Aug 23, 2014 at 1:47 PM, Seymore4Head > wrote: >> I am trying to do this example: >> http://openbookproject.net/pybiblio/practice/wilson/loan.php >> The instructions warn that floating point math can get messy so I >> cheated a li

Re: Working with decimals

2014-08-23 Thread Joel Goldstick
On Sat, Aug 23, 2014 at 1:47 PM, Seymore4Head wrote: > I am trying to do this example: > http://openbookproject.net/pybiblio/practice/wilson/loan.php > The instructions warn that floating point math can get messy so I > cheated a little bit to get me going. > > I made my program work by using numb

Re: Working with the set of real numbers

2014-03-06 Thread Chris Angelico
On Thu, Mar 6, 2014 at 11:27 PM, Oscar Benjamin wrote: > So my loop > > while x ** 2 - y > x * eps: > x = (x + y/x) / 2 > > and Chris' loop: > > while abs(guess1-guess2) > epsilon: > guess1 = n/guess2 > guess2 = (guess1 + guess2)/2 > > and now your loop > >

Re: Working with the set of real numbers

2014-03-06 Thread Oscar Benjamin
On 5 March 2014 12:57, Dave Angel wrote: > Oscar Benjamin Wrote in message: >> On 4 March 2014 23:20, Dave Angel wrote: >>> >>> On the assumption that division by 2 is very fast, and that a >>> general multiply isn't too bad, you could improve on Newton by >>> observing that the slope is 2.

Re: Working with the set of real numbers (was: Finding size of Variable)

2014-03-05 Thread Roy Smith
In article <5317e640$0$29985$c3e8da3$54964...@news.astraweb.com>, Steven D'Aprano wrote: > On Wed, 05 Mar 2014 21:31:51 -0500, Roy Smith wrote: > > > In article <53176225$0$29987$c3e8da3$54964...@news.astraweb.com>, > > Steven D'Aprano wrote: > > > >> Physics is the fundamental science, at l

Re: Working with the set of real numbers (was: Finding size of Variable)

2014-03-05 Thread Grant Edwards
On 2014-03-06, Roy Smith wrote: > In article <53176225$0$29987$c3e8da3$54964...@news.astraweb.com>, > Steven D'Aprano wrote: > >> Physics is the fundamental science, at least according to the >> physicists, and Real Soon Now they'll have a Theory Of Everything, >> something small enough to print

Re: Working with the set of real numbers (was: Finding size of Variable)

2014-03-05 Thread Chris Angelico
On Thu, Mar 6, 2014 at 2:06 PM, Steven D'Aprano wrote: > They ask a computer programmer to adjudicate who is right, so he writes a > program to print out all the primes: > > 1 is prime > 1 is prime > 1 is prime > 1 is prime > 1 is prime And he claimed that he was correct, because he had - as is k

Re: Working with the set of real numbers (was: Finding size of Variable)

2014-03-05 Thread Steven D'Aprano
On Wed, 05 Mar 2014 21:31:51 -0500, Roy Smith wrote: > In article <53176225$0$29987$c3e8da3$54964...@news.astraweb.com>, > Steven D'Aprano wrote: > >> Physics is the fundamental science, at least according to the >> physicists, and Real Soon Now they'll have a Theory Of Everything, >> something

Re: Working with the set of real numbers (was: Finding size of Variable)

2014-03-05 Thread Roy Smith
In article <53176225$0$29987$c3e8da3$54964...@news.astraweb.com>, Steven D'Aprano wrote: > Physics is the fundamental science, at least according to the physicists, > and Real Soon Now they'll have a Theory Of Everything, something small > enough to print on a tee-shirt, which will explain eve

Re: Working with the set of real numbers (was: Finding size of Variable)

2014-03-05 Thread Oscar Benjamin
On 5 March 2014 17:43, Steven D'Aprano wrote: > On Wed, 05 Mar 2014 12:21:37 +, Oscar Benjamin wrote: >> >> The argument that the sum of all natural numbers comes to -1/12 is just >> some kind of hoax. I don't think *anyone* seriously believes it. > > You would be wrong. I suggest you read the

Re: Working with the set of real numbers (was: Finding size of Variable)

2014-03-05 Thread Grant Edwards
On 2014-03-05, Chris Kaynor wrote: > On Wed, Mar 5, 2014 at 9:43 AM, Steven D'Aprano < > steve+comp.lang.pyt...@pearwood.info> wrote: > >> At one time, Euler summed an infinite series and got -1, from which he >> concluded that -1 was (in some sense) larger than infinity. I don't know >> what just

Re: Working with the set of real numbers (was: Finding size of Variable)

2014-03-05 Thread Chris Kaynor
On Wed, Mar 5, 2014 at 9:43 AM, Steven D'Aprano < steve+comp.lang.pyt...@pearwood.info> wrote: > At one time, Euler summed an infinite series and got -1, from which he > concluded that -1 was (in some sense) larger than infinity. I don't know > what justification he gave, but the way I think of it

Re: Working with the set of real numbers (was: Finding size of Variable)

2014-03-05 Thread Chris Angelico
On Thu, Mar 6, 2014 at 4:43 AM, Steven D'Aprano wrote: > Physics is the fundamental science, at least according to the physicists, > and Real Soon Now they'll have a Theory Of Everything, something small > enough to print on a tee-shirt, which will explain everything. At least > in principle. Eve

Re: Working with the set of real numbers

2014-03-05 Thread Steven D'Aprano
On Wed, 05 Mar 2014 12:50:06 +, Mark Lawrence wrote: > On 05/03/2014 12:21, Oscar Benjamin wrote: >> >> Why the dig at physicists? I think most physicists would be able to >> tell you that the sum of all natural numbers is not -1/12. In fact most >> people with very little background in mathem

Re: Working with the set of real numbers (was: Finding size of Variable)

2014-03-05 Thread Steven D'Aprano
On Wed, 05 Mar 2014 12:21:37 +, Oscar Benjamin wrote: > On 5 March 2014 07:52, Steven D'Aprano wrote: >> On Tue, 04 Mar 2014 23:25:37 -0500, Roy Smith wrote: >> >>> I stopped paying attention to mathematicians when they tried to >>> convince me that the sum of all natural numbers is -1/12. >>

Re: Working with the set of real numbers

2014-03-05 Thread Dave Angel
Dave Angel Wrote in message: > Oscar Benjamin Wrote in message: >> On 4 March 2014 23:20, Dave Angel wrote: >>> >>> If anyone is curious, I'll be glad to describe the algorithm; >>> I've never seen it published, before or since. I got my >>> inspiration from a method used in mechanical,

Re: Working with the set of real numbers

2014-03-05 Thread Dave Angel
Oscar Benjamin Wrote in message: > On 4 March 2014 23:20, Dave Angel wrote: >> >> One problem with complexity claims is that it's easy to miss some >> contributing time eaters. I haven't done any measuring on modern >> machines nor in python, but I'd assume that multiplies take >> *much* long

Re: Working with the set of real numbers

2014-03-05 Thread Mark Lawrence
On 05/03/2014 12:21, Oscar Benjamin wrote: Why the dig at physicists? I think most physicists would be able to tell you that the sum of all natural numbers is not -1/12. In fact most people with very little background in mathematics can tell you that. I'll put that one to the test tomorrow mo

Re: Working with the set of real numbers (was: Finding size of Variable)

2014-03-05 Thread Oscar Benjamin
On 5 March 2014 07:52, Steven D'Aprano wrote: > On Tue, 04 Mar 2014 23:25:37 -0500, Roy Smith wrote: > >> I stopped paying attention to mathematicians when they tried to convince >> me that the sum of all natural numbers is -1/12. > > I'm pretty sure they did not. Possibly a physicist may have tri

  1   2   3   4   5   >