Re: i'm a python newbie & wrote my first script, can someone critique it?

2016-06-12 Thread mad scientist jr
Thanks for your reply! On Saturday, June 11, 2016 at 2:41:39 PM UTC-4, MRAB wrote: > Drop the next 3 comment lines. They add visual clutter, and no useful info. > > ### > > # REFERENCE MODULES > >

Re: i'm a python newbie & wrote my first script, can someone critique it?

2016-06-11 Thread MRAB
On 2016-06-11 18:59, mad scientist jr wrote: Thanks to everyone for your replies. I see my script was as horrific as I feared, but I read all the responses and made a few changes. I'm not 100% sold on not checking types, but took it out, because it made sense that other programmers might

Re: i'm a python newbie & wrote my first script, can someone critique it?

2016-06-11 Thread Marc Brooks
Look into docstrings. They will make your code much more readable to a Python reader. On Sat, Jun 11, 2016 at 2:16 PM mad scientist jr wrote: > For those who don't want to have to wade through comments, here is a > version without so many comments: > > # For Python

Re: i'm a python newbie & wrote my first script, can someone critique it?

2016-06-11 Thread mad scientist jr
For those who don't want to have to wade through comments, here is a version without so many comments: # For Python 3.x # This script creates multiple numbered empty folders # in the desired location. To change the folder names # or location, edit function get_default_options. import datetime

Re: i'm a python newbie & wrote my first script, can someone critique it?

2016-06-11 Thread mad scientist jr
Thanks to everyone for your replies. I see my script was as horrific as I feared, but I read all the responses and made a few changes. I'm not 100% sold on not checking types, but took it out, because it made sense that other programmers might want to use some custom type with my functions

Re: i'm a python newbie & wrote my first script, can someone critique it?

2016-06-10 Thread Matt Wheeler
First of all welcome :) The other suggestions you've received so far are good so I won't repeat them... (note that in particular I've reused the names you've chosen in your program where I've given code examples, but that's purely for clarity and I agree with the others who've said you should use

Re: i'm a python newbie & wrote my first script, can someone critique it?

2016-06-10 Thread Larry Hudson via Python-list
On 06/10/2016 03:52 PM, mad scientist jr wrote: Is this group appropriate for that kind of thing? (If not sorry for posting this here.) So I wanted to start learning Python, and there is s much information online, which is a little overwhelming. I really learn best from doing, especially

Re: i'm a python newbie & wrote my first script, can someone critique it?

2016-06-10 Thread Joel Goldstick
On Fri, Jun 10, 2016 at 6:52 PM, mad scientist jr wrote: > Is this group appropriate for that kind of thing? > (If not sorry for posting this here.) > > So I wanted to start learning Python, and there is s much information > online, which is a little overwhelming.

Re: i'm a python newbie & wrote my first script, can someone critique it?

2016-06-10 Thread Marc Brooks
The structure of your program is really not that Pythonic. I'd recommend you take a look at PEP 8. https://www.python.org/dev/peps/pep-0008/ It's not perfect, but it's a good start to get a feel for how to structure your Python work. Marc On Fri, Jun 10, 2016 at 7:05 PM, Christopher Reimer <

Re: i'm a python newbie & wrote my first script, can someone critique it?

2016-06-10 Thread Christopher Reimer
Sent from my iPhone > On Jun 10, 2016, at 3:52 PM, mad scientist jr > wrote: > . > Now that it's done, I am wondering what kind of things I could do better. This is Python, not BASIC. Lay off on the CAP LOCK key and delete all the comments and separation blocks.

i'm a python newbie & wrote my first script, can someone critique it?

2016-06-10 Thread mad scientist jr
Is this group appropriate for that kind of thing? (If not sorry for posting this here.) So I wanted to start learning Python, and there is s much information online, which is a little overwhelming. I really learn best from doing, especially if it's something actually useful. I needed to

Re: Python newbie here! No module named settings

2015-04-12 Thread rdavis7408
On Thursday, June 2, 2011 at 10:29:48 AM UTC-5, Neeraj Agarwal wrote: Hello all, I'm a newbie to Python and its my 2nd day exploring it. I was trying to use Python wrapper for Google Charts API and was tweaking the examples. https://github.com/gak/pygooglechart/raw/master/examples/pie.py

Re: Case-insensitive sorting of strings (Python newbie)

2015-01-23 Thread Peter Otten
John Sampson wrote: I notice that the string method 'lower' seems to convert some strings (input from a text file) to Unicode but not others. This messes up sorting if it is used on arguments of 'sorted' since Unicode strings come before ordinary ones. Is there a better way of

Re: Case-insensitive sorting of strings (Python newbie)

2015-01-23 Thread Steven D'Aprano
John Sampson wrote: I notice that the string method 'lower' seems to convert some strings (input from a text file) to Unicode but not others. I don't think so. You're going to have to show an example. I *think* what you might be running into is an artifact of printing to a terminal, which may

Case-insensitive sorting of strings (Python newbie)

2015-01-23 Thread John Sampson
I notice that the string method 'lower' seems to convert some strings (input from a text file) to Unicode but not others. This messes up sorting if it is used on arguments of 'sorted' since Unicode strings come before ordinary ones. Is there a better way of case-insensitive sorting of strings

Re: Case-insensitive sorting of strings (Python newbie)

2015-01-23 Thread Michael Ströder
John Sampson wrote: I notice that the string method 'lower' seems to convert some strings (input from a text file) to Unicode but not others. This messes up sorting if it is used on arguments of 'sorted' since Unicode strings come before ordinary ones. I doubt that. Can you provide a short

Re: Case-insensitive sorting of strings (Python newbie)

2015-01-23 Thread Chris Angelico
On Sat, Jan 24, 2015 at 4:53 AM, Peter Otten __pete...@web.de wrote: Now the same with unicode. To read text with a specific encoding use either codecs.open() or io.open() instead of the built-in (replace utf-8 with your actual encoding): import io for line in io.open(tmp.txt,

Re: Case-insensitive sorting of strings (Python newbie)

2015-01-23 Thread Chris Angelico
On Sat, Jan 24, 2015 at 6:14 AM, Marko Rauhamaa ma...@pacujo.net wrote: Well, if Python can't, then who can? Probably nobody in the world, not generically, anyway. Example: print(re\u0301sume\u0301) résumé print(r\u00e9sum\u00e9) résumé print(re\u0301sume\u0301 ==

Re: Case-insensitive sorting of strings (Python newbie)

2015-01-23 Thread Marko Rauhamaa
Peter Otten __pete...@web.de: The standard recommendation is to convert bytes to unicode as early as possible and only manipulate unicode. Unicode doesn't get you off the hook (as you explain later in your post). Upper/lowercase as well as collation order is ambiguous. Python even with decent

python newbie

2014-06-18 Thread Maura E Monville
My supervisor has palmed me off with a python code, written by a collaborator, which implements an algorithm aimed at denoising the dose distribution (energy per unit mass) output from a radiation transport Monte Carlo code. My task is to translate the python code into a MatLab code. A colleague

Re: python newbie

2014-06-18 Thread Steven D'Aprano
On Wed, 18 Jun 2014 05:10:03 -0700, Maura E Monville wrote: My supervisor has palmed me off with a python code, written by a collaborator, which implements an algorithm aimed at denoising the dose distribution (energy per unit mass) output from a radiation transport Monte Carlo code. My task

Re: python newbie

2014-06-18 Thread Maura E Monville
On Wednesday, June 18, 2014 1:50:54 PM UTC+1, Steven D'Aprano wrote: On Wed, 18 Jun 2014 05:10:03 -0700, Maura E Monville wrote: My supervisor has palmed me off with a python code, written by a collaborator, which implements an algorithm aimed at denoising the dose distribution

Re: python newbie

2014-06-18 Thread Jim Gibson
In article fa433710-0953-4b4a-96f6-2f7d1b9af...@googlegroups.com, Maura E Monville maura.monvi...@gmail.com wrote: My supervisor has palmed me off with a python code, written by a collaborator, which implements an algorithm aimed at denoising the dose distribution (energy per unit mass) output

Total Python Newbie needs geting started info.

2013-11-20 Thread Ev J
I am learning Python and wish to develop GUI applications to run on Windows. I have installed the Visual Studio integrated shell (Ver. 12.0.21005.1 REL) IDE and the Python 3.3 interpreter. I have gone through some of the 3.3 tutorial available at http://docs.python.org/3.3/tutorial/. The

Re: Total Python Newbie needs geting started info.

2013-11-20 Thread Chris Angelico
On Thu, Nov 21, 2013 at 3:03 AM, Ev J shorepoin...@gmail.com wrote: Before I go too far down this road, I need to know if I can/should use this environment to develop GUI applications. Is there graphical support for this - for example I can I just insert/move/set properties of buttons, combo

Re: Total Python Newbie needs geting started info.

2013-11-20 Thread Alister
On Thu, 21 Nov 2013 03:14:44 +1100, Chris Angelico wrote: On Thu, Nov 21, 2013 at 3:03 AM, Ev J shorepoin...@gmail.com wrote: Before I go too far down this road, I need to know if I can/should use this environment to develop GUI applications. Is there graphical support for this - for example

Re: Total Python Newbie needs geting started info.

2013-11-20 Thread Rod Person
On 11/20/2013 11:03 AM, Ev J wrote: I am learning Python and wish to develop GUI applications to run on Windows. I have installed the Visual Studio integrated shell (Ver. 12.0.21005.1 REL) IDE and the Python 3.3 interpreter. I have gone through some of the 3.3 tutorial available at

Re: Total Python Newbie needs geting started info.

2013-11-20 Thread Christopher Welborn
On 11/20/2013 10:03 AM, Ev J wrote: I am learning Python and wish to develop GUI applications to run on Windows. I have installed the Visual Studio integrated shell (Ver. 12.0.21005.1 REL) IDE and the Python 3.3 interpreter. I have gone through some of the 3.3 tutorial available at

Re: Python newbie trying to embed in C++

2013-02-28 Thread Marwan Badawi
On 27/02/2013 10:26, Ian Kelly wrote: On Wed, Feb 27, 2013 at 1:51 AM, Marwan lar...@free.fr wrote: When I run the generated exe, I get errors about the functions not existing... TestPython.exe test Hello AttributeError: 'module' object has no attribute 'Hello' Cannot find function Hello

Re: Python newbie trying to embed in C++

2013-02-28 Thread Marwan Badawi
On 27/02/2013 16:17, Christian Gollwitzer wrote: Am 27.02.13 09:51, schrieb Marwan: And I'd appreciate it if you could give me pointers to how to easily call Python from C++. Maybe you can use boost::python? http://www.boost.org/doc/libs/1_53_0/libs/python/doc/ Cave: I haven't used it and

Re: Python newbie trying to embed in C++

2013-02-28 Thread Gisle Vanem
Marwan Badawi marwan.bad...@inria.fr wrote: I just noticed that my reply went to the message sender and not to the newsgroup, so I'm posting again: thanks, I'll look into that. Yes, I often do that too; i.e. I'm subscribed to python-list@python.org and get all messages from comp.lang.python

Re: Python newbie trying to embed in C++

2013-02-28 Thread Michael Torrie
On 02/28/2013 03:47 AM, Gisle Vanem wrote: I saw you uses Thunderbird on Windows. I'm not sure how it by default handles a reply-to when there is no Reply-to field in the header. To the address in From / Sender or what? Thunderbird has a handy, reply to list button that works every time no

Python newbie trying to embed in C++

2013-02-27 Thread Marwan
Hello all, I'm new to Python and just starting to learn it. For he needs of my project, I need to call some specific methods in Python scripts from C++. For now, I just compiled the example in the Python documentation about Pure Embedding to try it out (

Re: Python newbie trying to embed in C++

2013-02-27 Thread Ian Kelly
On Wed, Feb 27, 2013 at 1:51 AM, Marwan lar...@free.fr wrote: When I run the generated exe, I get errors about the functions not existing... TestPython.exe test Hello AttributeError: 'module' object has no attribute 'Hello' Cannot find function Hello test is the name of a module in the

Re: Python newbie trying to embed in C++

2013-02-27 Thread Christian Gollwitzer
Am 27.02.13 09:51, schrieb Marwan: And I'd appreciate it if you could give me pointers to how to easily call Python from C++. Maybe you can use boost::python? http://www.boost.org/doc/libs/1_53_0/libs/python/doc/ Cave: I haven't used it and don't know if it is up-to-date. Christian

Re: Python newbie trying to embed in C++

2013-02-27 Thread Terry Reedy
On 2/27/2013 3:51 AM, Marwan wrote: Hello all, I'm new to Python and just starting to learn it. For he needs of my project, I need to call some specific methods in Python scripts from C++. For now, I just compiled the example in the Python documentation about Pure Embedding to try it out (

Re: Python Newbie

2013-02-26 Thread Larry Hudson
On 02/24/2013 02:43 PM, piterrr.dolin...@gmail.com wrote: snip ... But for the moment I am trying to imitate familiar ground. snip This is EXACTLY why you're having trouble grasping Python. Python is a different language and requires a different mind-set and different approach. In this, it

Re: Python Newbie

2013-02-26 Thread Matej Cepl
On 2013-02-23, 15:51 GMT, Chris Angelico wrote: When you learn your first language, you think you're learning to program, but that's not really accurate. Once you've learned half a dozen, you begin to understand something of the art of coding as distinct from any particular language; after

Re: Python Newbie

2013-02-26 Thread Matej Cepl
On 2013-02-23, 18:44 GMT, jmfauth wrote: Very easy to explain: wrong, incorrect, naive unicode handling. PLONK! -- http://mail.python.org/mailman/listinfo/python-list

Re: Python Newbie

2013-02-26 Thread rurpy
On 02/26/2013 01:32 AM, Larry Hudson wrote: On 02/24/2013 02:43 PM, piterrr.dolin...@gmail.com wrote: snip ... But for the moment I am trying to imitate familiar ground. snip This is EXACTLY why you're having trouble grasping Python. Python is a different language and requires a

Re: Python Newbie

2013-02-26 Thread Jean-Michel Pichavant
- Original Message - Hi guys, Question. Have this code intX = 32 # decl + init int var intX_asString = None # decl + init with NULL string var intX_asString = intX.__str__ ()# convert int to string What are these ugly underscores

Re: Python Newbie

2013-02-26 Thread Ethan Furman
On 02/26/2013 10:23 AM, ru...@yahoo.com wrote: On 02/26/2013 01:32 AM, Larry Hudson wrote: Python variables do NOT have any data type. I have no problem interpreting the OP's statement as meaning that he wanted to use a Python variable to consistently reference a particular type and wanted a

Re: Python Newbie

2013-02-26 Thread Piterrr
Jean-Michel Pichavant jeanmic...@sequans.com wrote in message news:mailman.2567.1361905815.2939.python-l...@python.org... - Original Message - Hi guys, Question. Have this code intX = 32 # decl + init int var intX_asString = None # decl + init

Re: Python Newbie

2013-02-26 Thread Chris Angelico
On Wed, Feb 27, 2013 at 6:42 AM, Piterrr piotr...@optonline.net wrote: This reminds me, when I first started working with databases and saw an error msg which said that my query had ambiguous columns I laughed for 1/2 hr. I found it incredibly exitaining that a 100% deterministic piece of

Re: Python Newbie

2013-02-26 Thread rurpy
On Tuesday, February 26, 2013 11:59:51 AM UTC-7, Ethan Furman wrote: On 02/26/2013 10:23 AM, ru...@yahoo.com wrote: On 02/26/2013 01:32 AM, Larry Hudson wrote: Python variables do NOT have any data type. I have no problem interpreting the OP's statement as meaning that he wanted to use a

Re: Python Newbie

2013-02-25 Thread Serhiy Storchaka
On 24.02.13 17:52, Chris Angelico wrote: By the way, when you're asking a completely new question, it usually helps to do so as a brand new thread (not a reply) and with a new subject line. Otherwise, you risk people losing the new question among the discussion of the old. You risk people

Re: Python Newbie

2013-02-25 Thread Nick Mellor
Hi Piterr, It's interesting how strong our habits are, isn't it? It's most likely you've just got a bit of culture shock. I've used C# quite a bit as well as Python. I like them both. What I like about Python is how it manages to be clear and terse at the same time. if (flag==1) { code }

Re: Python Newbie

2013-02-24 Thread Vito De Tullio
piterrr.dolin...@gmail.com wrote: You see, Javascript, for one, behaves the same way as Python (no variable declaration) but JS has curly braces and you know the variable you have just used is limited in scope to the code within the { }. With Python, you have to search the whole file. I

Re: Python Newbie

2013-02-24 Thread Mark Lawrence
On 24/02/2013 04:20, Larry Hudson wrote: On 02/23/2013 03:46 PM, piterrr.dolin...@gmail.com wrote: Hi all, snip ... I have discovered today there is no do...while type loop. [Sigh] No biggie. This is easily simulated with: while True: ... if exit condition: break Less

Re: Python Newbie

2013-02-24 Thread piterrr . dolinski
Hi guys, Question. Have this code intX = 32 # decl + init int var intX_asString = None # decl + init with NULL string var intX_asString = intX.__str__ ()# convert int to string What are these ugly underscores for?

Re: Python Newbie

2013-02-24 Thread Chris Angelico
On Mon, Feb 25, 2013 at 2:46 AM, piterrr.dolin...@gmail.com wrote: Hi guys, Question. Have this code intX = 32 # decl + init int var intX_asString = None # decl + init with NULL string var intX_asString = intX.__str__ ()# convert int to string

Re: Python Newbie

2013-02-24 Thread Roy Smith
In article mailman.2410.1361721167.2939.python-l...@python.org, Chris Angelico ros...@gmail.com wrote: The dunder methods (double underscore, leading and trailing), also called magic methods, are the implementations of various special features. For instance, indexing foo[1] is implemented

Re: Python Newbie

2013-02-24 Thread Mark Lawrence
On 22/02/2013 21:37, piterrr.dolin...@gmail.com wrote: if (some statement):# short form rather than if (some statement == true):# long form What all those ugly brackets are for? Peter -- Cheers. Mark Lawrence -- http://mail.python.org/mailman/listinfo/python-list

Re: Python Newbie

2013-02-24 Thread Steven D'Aprano
On Sun, 24 Feb 2013 07:46:07 -0800, piterrr.dolinski wrote: Hi guys, Question. Have this code intX = 32 # decl + init int var intX_asString = None # decl + init with NULL string var intX_asString = intX.__str__ ()# convert int to string

Re: Python Newbie

2013-02-24 Thread Michael Torrie
On 02/24/2013 10:37 AM, Dennis Lee Bieber wrote: Decided to look up the VAX/VMS scheme... If you know the condition code for a message, you can use F$MESSAGE to translate the code to its associated message. For example: $ WRITE SYS$OUTPUT F$MESSAGE(%X0001) %SYSTEM-S-NORMAL,

Re: Python Newbie

2013-02-24 Thread Roy Smith
In article mailman.2420.1361728619.2939.python-l...@python.org, Michael Torrie torr...@gmail.com wrote: It's interesting to note that Windows NT sort of descends from VMS. More than sort of. Dave Cutler was the chief architect of both. -- http://mail.python.org/mailman/listinfo/python-list

Re: Python Newbie

2013-02-24 Thread Grant Edwards
On 2013-02-23, Chris Angelico ros...@gmail.com wrote: It's worth noting, though, that there are self-perpetuating aspects to it. I can happily distribute a .py file to a Linux audience, because many Linux distros come with a Python already installed, or at very least can grab one easily via

Re: Python Newbie

2013-02-24 Thread piterrr . dolinski
To demonstrate that the person who wrote this code was not a good Python programmer. I hope it wasn't you :-) This person obviously had a very basic, and confused, understanding of Python. And, quite frankly, was probably not a very good programmer of *any* language: -

Re: Python Newbie

2013-02-24 Thread piterrr . dolinski
if (some statement):# short form rather than if (some statement == true):# long form What all those ugly brackets are for? Mark, Back in the day when C was king, or take many newer long established languages (C#, Java), the use of () has been widespread

Re: Python Newbie

2013-02-24 Thread Mitya Sirenef
On 02/24/2013 02:40 PM, piterrr.dolin...@gmail.com wrote: if (some statement): # short form rather than if (some statement == true): # long form What all those ugly brackets are for? Mark, Back in the day when C was king, or take many newer long established languages (C#, Java),

Re: Python Newbie

2013-02-24 Thread Chris Angelico
On Mon, Feb 25, 2013 at 5:19 AM, Grant Edwards invalid@invalid.invalid wrote: On 2013-02-23, Chris Angelico ros...@gmail.com wrote: It's worth noting, though, that there are self-perpetuating aspects to it. I can happily distribute a .py file to a Linux audience, because many Linux distros

Re: Python Newbie

2013-02-24 Thread Michael Ross
On Sun, 24 Feb 2013 20:40:05 +0100, piterrr.dolin...@gmail.com wrote: if (some statement): # short form rather than if (some statement == true): # long form What all those ugly brackets are for? Mark, Back in the day when C was king, or take many newer long

Re: Python Newbie

2013-02-24 Thread MRAB
On 2013-02-24 19:40, piterrr.dolin...@gmail.com wrote: if (some statement):# short form rather than if (some statement == true):# long form What all those ugly brackets are for? Mark, Back in the day when C was king, or take many newer long established languages (C#,

Re: Python Newbie

2013-02-24 Thread Chris Angelico
On Mon, Feb 25, 2013 at 7:34 AM, MRAB pyt...@mrabarnett.plus.com wrote: Some languages require parentheses, others don't. C does. C++, Java and C# are descended from, or influenced by, C. Algol didn't (doesn't?). Pascal, Modula-2, Oberon, Ada, and others don't. Parentheses are used where

Re: Python Newbie

2013-02-24 Thread Mark Lawrence
On 24/02/2013 19:40, piterrr.dolin...@gmail.com wrote: if (some statement):# short form rather than if (some statement == true):# long form What all those ugly brackets are for? Mark, Back in the day when C was king, or take many newer long established languages (C#,

Re: Python Newbie

2013-02-24 Thread Ethan Furman
On 02/24/2013 11:40 AM, piterrr.dolin...@gmail.com wrote: Back in the day when C was king, or take many newer long established languages (C#, Java), the use of () has been widespread and mandated by the compilers. I have never heard anyone moan about the requirement to use parentheses. Now

Re: Python Newbie

2013-02-24 Thread Chris Angelico
On Mon, Feb 25, 2013 at 7:34 AM, Ethan Furman et...@stoneleaf.us wrote: One of the things I love about Python is its ability to get out of the way and let me work: - no variable declarations, just use 'em - no type declarations, just use 'em - no need to remember what's an object and

Re: Python Newbie

2013-02-24 Thread Roy Smith
In article mailman.2434.1361738581.2939.python-l...@python.org, Chris Angelico ros...@gmail.com wrote: On Mon, Feb 25, 2013 at 7:34 AM, MRAB pyt...@mrabarnett.plus.com wrote: Some languages require parentheses, others don't. C does. C++, Java and C# are descended from, or influenced by,

Re: Python Newbie

2013-02-24 Thread Roy Smith
In article mailman.2438.1361739512.2939.python-l...@python.org, Chris Angelico ros...@gmail.com wrote: no need to remember what's an object and what's not -- everything is an object Well, not quite everything. If I write: if foo: do_this() and_this() the code block making up the

Re: Python Newbie

2013-02-24 Thread Joshua Landau
On 24 February 2013 19:29, piterrr.dolin...@gmail.com wrote: Hi. Steve, I don't know where you have been over the past couple of days but it is widely known (if the thread title is any indication) that I am indeed very new to Python, but not new to programming in general. To give a bit of

Re: Python Newbie

2013-02-24 Thread Joshua Landau
On 24 February 2013 20:48, Roy Smith r...@panix.com wrote: In article mailman.2434.1361738581.2939.python-l...@python.org, Chris Angelico ros...@gmail.com wrote: On Mon, Feb 25, 2013 at 7:34 AM, MRAB pyt...@mrabarnett.plus.com wrote: Some languages require parentheses, others don't.

Re: Python Newbie

2013-02-24 Thread Chris Angelico
On Mon, Feb 25, 2013 at 8:35 AM, Joshua Landau joshua.landau...@gmail.com wrote: def solve_quadratic(a, b, c): Solve a quadratic equation of the form ax² + bx + c = 0 The result will be a tuple of the two results; the results can be equal if the determinant is 0. This supports imaginary

Re: Python Newbie

2013-02-24 Thread Mitya Sirenef
On 02/24/2013 04:44 PM, Chris Angelico wrote: On Mon, Feb 25, 2013 at 8:08 AM, Roy Smith r...@panix.com wrote: In article mailman.2438.1361739512.2939.python-l...@python.org, Chris Angelico ros...@gmail.com wrote: no need to remember what's an object and what's not -- everything is an

Re: Python Newbie

2013-02-24 Thread Ethan Furman
On 02/24/2013 12:58 PM, Chris Angelico wrote: On Mon, Feb 25, 2013 at 7:34 AM, Ethan Furman et...@stoneleaf.us wrote: - no variable declarations, just use 'em Variable declarations can go either way; Python requires you to name all globals that you mutate I'm not sure what you mean --

Re: Python Newbie

2013-02-24 Thread piterrr . dolinski
Josh, Not thank you for your malicious post. I think you are missing the point here. My source code was just a dummy to offer context for the question I wanted to ask. Further down the line, if I ever feel I don't need to pseudo-declare variables I will stop doing it. But for the moment I am

Re: Python Newbie

2013-02-24 Thread Dave Angel
On 02/24/2013 10:46 AM, piterrr.dolin...@gmail.com wrote: Hi guys, Question. Have this code intX = 32 # decl + init int var intX_asString = None # decl + init with NULL string var None is not a str, and it's not a NULL string var Perhaps what you

Re: Python Newbie

2013-02-24 Thread Joel Goldstick
On Sun, Feb 24, 2013 at 5:43 PM, piterrr.dolin...@gmail.com wrote: Josh, Not thank you for your malicious post. I think you are missing the point here. My source code was just a dummy to offer context for the question I wanted to ask. Further down the line, if I ever feel I don't need to

Re: Python Newbie

2013-02-24 Thread Joshua Landau
On 24 February 2013 22:43, piterrr.dolin...@gmail.com wrote: Josh, Not thank you for your malicious post. Be careful, us programmers do *eventually* catch on to who is a troll, and if you say things like that we may eventually mark you off as just to hostile. I *honestly* meant no malice or

Re: Python Newbie

2013-02-24 Thread Joshua Landau
On 24 February 2013 22:08, Chris Angelico ros...@gmail.com wrote: On Mon, Feb 25, 2013 at 8:35 AM, Joshua Landau joshua.landau...@gmail.com wrote: def solve_quadratic(a, b, c): Solve a quadratic equation of the form ax² + bx + c = 0 The result will be a tuple of the two results; the

Re: Python Newbie

2013-02-24 Thread Joshua Landau
On 24 February 2013 23:18, Oscar Benjamin oscar.j.benja...@gmail.comwrote: On 24 February 2013 21:35, Joshua Landau joshua.landau...@gmail.com wrote: determinant = b**2 - 4*a*c It's called the discriminant. A determinant is something altogether different. *cries at own idiocy* Thank

Re: Python Newbie

2013-02-24 Thread Albert Hopkins
Most of what gets hung in art galleries these days is far less visually pleasing than well-written code. +1 QOTW -- http://mail.python.org/mailman/listinfo/python-list

Re: Python Newbie

2013-02-24 Thread piterrr . dolinski
intX = 32 # decl + init int var How is it not obvious that intX is an integer *without* the comment? Indeed the assignment is enough to deduce intX is an int. The comment is there to let me know it is unlikely intX appears earlier in the code. Please, let me do

Re: Python Newbie

2013-02-24 Thread Chris Angelico
On Mon, Feb 25, 2013 at 9:33 AM, Ethan Furman et...@stoneleaf.us wrote: On 02/24/2013 12:58 PM, Chris Angelico wrote: On Mon, Feb 25, 2013 at 7:34 AM, Ethan Furman et...@stoneleaf.us wrote: - no variable declarations, just use 'em Variable declarations can go either way; Python

Re: Python Newbie

2013-02-24 Thread Chris Angelico
On Mon, Feb 25, 2013 at 10:38 AM, piterrr.dolin...@gmail.com wrote: intX = 32 # decl + init int var How is it not obvious that intX is an integer *without* the comment? Indeed the assignment is enough to deduce intX is an int. The comment is there to let me know it

Re: Python Newbie

2013-02-24 Thread Ethan Furman
On 02/24/2013 03:38 PM, piterrr.dolin...@gmail.com wrote: intX = 32 # decl + init int var How is it not obvious that intX is an integer *without* the comment? Indeed the assignment is enough to deduce intX is an int. The comment is there to let me know it is

Re: Python Newbie

2013-02-24 Thread piterrr . dolinski
For example (I believe it's already been mentioned) declaring intX with some integer value does *nothing* to maintain X as an integer: -- intX = 32 -- intX = intX / 3.0 -- intX 10.66 Yes I did see that it is possible to redefine the type of a variable. But I don't

Re: Python Newbie

2013-02-24 Thread Joshua Landau
On 25 February 2013 00:08, piterrr.dolin...@gmail.com wrote: For example (I believe it's already been mentioned) declaring intX with some integer value does *nothing* to maintain X as an integer: -- intX = 32 -- intX = intX / 3.0 -- intX 10.66 Yes I did see that

Re: Python Newbie

2013-02-24 Thread Mark Lawrence
On 25/02/2013 00:08, piterrr.dolin...@gmail.com wrote: For example (I believe it's already been mentioned) declaring intX with some integer value does *nothing* to maintain X as an integer: -- intX = 32 -- intX = intX / 3.0 -- intX 10.66 Yes I did see that it is possible to

Re: Python Newbie

2013-02-24 Thread Ethan Furman
On 02/24/2013 04:08 PM, piterrr.dolin...@gmail.com wrote: For example (I believe it's already been mentioned) declaring intX with some integer value does *nothing* to maintain X as an integer: -- intX = 32 -- intX = intX / 3.0 -- intX 10.66 Yes I did see that it is possible to

Re: Python Newbie

2013-02-24 Thread Steven D'Aprano
On Sun, 24 Feb 2013 16:08:01 -0500, Roy Smith wrote: In article mailman.2438.1361739512.2939.python-l...@python.org, Chris Angelico ros...@gmail.com wrote: no need to remember what's an object and what's not -- everything is an object Well, not quite everything. If I write: if

Re: Python Newbie

2013-02-24 Thread Roy Smith
In article mailman.2461.1361749985.2939.python-l...@python.org, Ethan Furman et...@stoneleaf.us wrote: On 02/24/2013 03:38 PM, piterrr.dolin...@gmail.com wrote: intX = 32 # decl + init int var How is it not obvious that intX is an integer *without* the comment?

Re: Python Newbie

2013-02-24 Thread Oscar Benjamin
On 25 February 2013 00:08, piterrr.dolin...@gmail.com wrote: Chris Angelico wrote: For example (I believe it's already been mentioned) declaring intX with some integer value does *nothing* to maintain X as an integer: -- intX = 32 -- intX = intX / 3.0 -- intX 10.66 Yes I

Re: Python Newbie

2013-02-24 Thread Roy Smith
In article da0ec7a1-decd-4cfb-9a0b-5722879f5...@googlegroups.com, piterrr.dolin...@gmail.com wrote: Yes I did see that it is possible to redefine the type of a variable. But I don't think I would ever do this intentionally One does not need language features to protect themselves against

Re: Python Newbie

2013-02-24 Thread Steven D'Aprano
On Sun, 24 Feb 2013 11:40:05 -0800, piterrr.dolinski wrote: if (some statement): # short form rather than if (some statement == true): # long form What all those ugly brackets are for? Mark, Back in the day when C was king, or take many newer long

Re: Python Newbie

2013-02-24 Thread Steven D'Aprano
On Sun, 24 Feb 2013 16:08:06 -0800, piterrr.dolinski wrote: For example (I believe it's already been mentioned) declaring intX with some integer value does *nothing* to maintain X as an integer: -- intX = 32 -- intX = intX / 3.0 -- intX 10.66 Yes I did see that it is

Re: Python Newbie

2013-02-24 Thread Steven D'Aprano
On Sun, 24 Feb 2013 17:40:54 -0500, Mitya Sirenef wrote: But if block doesn't have to be inside a function, right? It needs to be inside a module, but then again everything is inside a module, but it wouldn't be very object-oriented if the module was the only object in Python :-). Python

Re: Python Newbie

2013-02-24 Thread Chris Angelico
On Mon, Feb 25, 2013 at 11:45 AM, Oscar Benjamin oscar.j.benja...@gmail.com wrote: On 25 February 2013 00:08, piterrr.dolin...@gmail.com wrote: Chris Angelico wrote: For example (I believe it's already been mentioned) declaring intX with some integer value does *nothing* to maintain X as

Re: Python Newbie

2013-02-24 Thread Chris Angelico
On Mon, Feb 25, 2013 at 12:04 PM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: Not at all. The only difference is whether you get a compiler error or a runtime error. Instead of: 10 Write code. 20 Compile. 30 If compiler error, GO TO 10. 40 REM code compiles, but it still

Re: Python Newbie

2013-02-24 Thread Michael Torrie
On 02/24/2013 03:40 PM, Mitya Sirenef wrote: But if block doesn't have to be inside a function, right? It needs to be inside a module, but then again everything is inside a module, but it wouldn't be very object-oriented if the module was the only object in Python :-). A module indeed fits

Re: Python Newbie

2013-02-24 Thread Michael Torrie
On 02/24/2013 06:04 PM, Steven D'Aprano wrote: Variables do not have types in Python. Reset your thinking. Python is a dynamic language with name bindings and strongly-typed objects, not a static language with strongly-typed variables. If you don't understand the difference, ask. But so

  1   2   3   4   5   >