Two more newbie questions

2014-07-18 Thread Martin S
My little newbie app is now coming along nicely. It calculates both LASK and Elo ratings for chess, so basic functionality is pretty much complete for my needs. Now, a/ What is the easiest way of putting a web interface on this CLI application. I've been looking at various web frameworks but that

Re: Two more newbie questions

2014-07-18 Thread Ben Finney
Martin S shieldf...@gmail.com writes: a/ What is the easiest way of putting a web interface on this CLI application. I've been looking at various web frameworks but that seems pretty much targeted more towards larger projects. Not slapping a gui on a cli application. Any pointers and

Re: Two more newbie questions

2014-07-18 Thread Shieldfire
On fre, 2014-07-18 at 18:23 +1000, Ben Finney wrote: Martin S shieldf...@gmail.com writes: a/ What is the easiest way of putting a web interface on this CLI application. I've been looking at various web frameworks but that seems pretty much targeted more towards larger projects. Not

Re: Two more newbie questions

2014-07-18 Thread Ben Finney
Shieldfire shieldf...@gmail.com writes: On fre, 2014-07-18 at 18:23 +1000, Ben Finney wrote: So, if by “slap a GUI onto” you mean something that is a no-frills plain-HTML form, with essentially no assistance for the user and no error handling, this will be a lot simpler to implement than

Newbie questions on Python

2013-04-16 Thread idkfaidkfaidkfa
Hi all, i'm programming in python for the first time (usually i use C as programming language). I don't understand these results: a=[1,2,3,4,5] a[:-1] [1, 2, 3, 4] a[::-1] [5, 4, 3, 2, 1] a[2::-1] [3, 2, 1] what does a[2::-1] means? Thanks --

Re: Newbie questions on Python

2013-04-16 Thread Chris Angelico
On Wed, Apr 17, 2013 at 1:20 AM, idkfaidkfaid...@gmail.com wrote: Hi all, i'm programming in python for the first time (usually i use C as programming language). I don't understand these results: a=[1,2,3,4,5] a[:-1] [1, 2, 3, 4] a[::-1] [5, 4, 3, 2, 1] a[2::-1] [3, 2, 1] what does

Re: Newbie questions on Python

2013-04-16 Thread Matt Jones
When slicing: l[start:end:step] In your example of a[2::-1] you are reversing the list by using a step of -1, then you are slicing at index 2 (third element). *Matt Jones* On Tue, Apr 16, 2013 at 10:30 AM, Chris Angelico ros...@gmail.com wrote: On Wed, Apr 17, 2013 at 1:20 AM,

Re: Newbie questions on Python

2013-04-16 Thread Neil Cerutti
On 2013-04-16, idkfaidkfaid...@gmail.com idkfaidkfaid...@gmail.com wrote: Hi all, i'm programming in python for the first time (usually i use C as programming language). I don't understand these results: a=[1,2,3,4,5] a[:-1] [1, 2, 3, 4] a[::-1] [5, 4, 3, 2, 1] a[2::-1] [3, 2, 1] The

Re: Newbie questions on Python

2013-04-16 Thread Lele Gaifax
Neil Cerutti ne...@norwich.edu writes: Imagine something like the following for loop taking place somewhere: for (int i = 2; i = 0; --i) { fprintf(a[i]); } Neil most probably meant for (int i = 2; i = 0; --i) { fprintf(a[i]); } where fprintf is actually a fictitious do_something

Re: Newbie questions on Python

2013-04-16 Thread Neil Cerutti
On 2013-04-16, Lele Gaifax l...@metapensiero.it wrote: Neil Cerutti ne...@norwich.edu writes: Imagine something like the following for loop taking place somewhere: for (int i = 2; i = 0; --i) { fprintf(a[i]); } Neil most probably meant for (int i = 2; i = 0; --i) {

Re: Newbie questions on Python

2013-04-16 Thread Walter Hurry
On Wed, 17 Apr 2013 01:30:03 +1000, Chris Angelico wrote: By the way, regarding your email address: there are no cheat codes in Python ROFLMAO. Incidentally, my son used to use IDDQD rather than IDKFA. I of course spurned all such, since I preferred to do it the hard way. Thus I was Doomed.

Re: Newbie questions on Python

2013-04-16 Thread Chris Angelico
On Wed, Apr 17, 2013 at 7:40 AM, Walter Hurry walterhu...@lavabit.com wrote: On Wed, 17 Apr 2013 01:30:03 +1000, Chris Angelico wrote: By the way, regarding your email address: there are no cheat codes in Python ROFLMAO. Incidentally, my son used to use IDDQD rather than IDKFA. I of course

Re: Newbie questions on import cmd line run

2012-05-18 Thread gwhite
On May 16, 9:33 pm, Steven D'Aprano steve +comp.lang.pyt...@pearwood.info wrote: On Wed, 16 May 2012 18:45:39 -0700, gwhite wrote: #! what is supposed to go here? # Filename: newbie00.py Supposed to? Nothing -- it is completely optional. #! (hash-bang) lines currently do nothing on

Re: Newbie questions on import cmd line run

2012-05-18 Thread gwhite
On May 16, 9:54 pm, alex23 wuwe...@gmail.com wrote: On May 17, 11:45 am, gwhite gwh...@ti.com wrote: 1.  If running from the system command line, or the Sypder run button, __name__ is __main__ rather than newbie00, as seen above. So, how would I get the file name newbie00.py in these

Re: Newbie questions on import cmd line run

2012-05-17 Thread Dave Angel
On 05/17/2012 12:54 AM, alex23 wrote: On May 17, 11:45 am, gwhite gwh...@ti.com wrote: SNIP I don't think that only-one-import is true for scripts that are run from the command line, though. They can exist as both '__main__' and their actual name in the module table. (Someone please correct

Re: Newbie questions on import cmd line run

2012-05-17 Thread Mark Lawrence
On 17/05/2012 05:29, Chris Rebert wrote: On Wed, May 16, 2012 at 6:45 PM, gwhitegwh...@ti.com wrote: #!what is supposed to go here? That's a shebang line. See http://en.wikipedia.org/wiki/Shebang_(Unix) It's doesn't matter at all since you're on Windows. On Unix-like systems, one typically

Re: Newbie questions on import cmd line run

2012-05-17 Thread Ross Ridge
Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: #! (hash-bang) lines currently do nothing on Windows machines, they are just comments. However, on Unix and Linux machines (and Macintosh?) they are interpreted by the shell (equivalent to cmd.exe or command.com), in order to tell the

Newbie questions on import cmd line run

2012-05-16 Thread gwhite
Hi, I am a newbie running the latest pythonxy (2.7.2.1) spyder and python 2.7.2. I suspect my questions are mostly basic to python, and not specific to Spyder or iPython. Note: Up until now, I mainly used MATLAB, and thus need to de-program myself appropriately. I use Win7-64. I wrote the

Re: Newbie questions on import cmd line run

2012-05-16 Thread Terry Reedy
On 5/16/2012 9:45 PM, gwhite wrote: Hi, I am a newbie running the latest pythonxy (2.7.2.1) spyder and python 2.7.2. I suspect my questions are mostly basic to python, and not specific to Spyder or iPython. Note: Up until now, I mainly used MATLAB, and thus need to de-program myself

Re: Newbie questions on import cmd line run

2012-05-16 Thread Chris Rebert
On Wed, May 16, 2012 at 6:45 PM, gwhite gwh...@ti.com wrote: Hi, I am a newbie running the latest pythonxy (2.7.2.1) spyder and python 2.7.2.   I suspect my questions are mostly basic to python, and not specific to Spyder or iPython. Note: Up until now, I mainly used MATLAB, and thus need

Re: Newbie questions on import cmd line run

2012-05-16 Thread Steven D'Aprano
On Wed, 16 May 2012 18:45:39 -0700, gwhite wrote: #! what is supposed to go here? # Filename: newbie00.py Supposed to? Nothing -- it is completely optional. #! (hash-bang) lines currently do nothing on Windows machines, they are just comments. However, on Unix and Linux machines (and

Re: Newbie questions on import cmd line run

2012-05-16 Thread alex23
On May 17, 11:45 am, gwhite gwh...@ti.com wrote: 1.  If running from the system command line, or the Sypder run button, __name__ is __main__ rather than newbie00, as seen above. So, how would I get the file name newbie00.py in these two noted cases? You can get it from the file name:

Re: [newbie questions] if conditions - if isset - if empty

2012-04-16 Thread Jean-Michel Pichavant
Mahmoud Abdel-Fattah wrote: Hello, I'm coming from PHP background ant totally new to Python, I just started using scrapy, but has some generic question in python. 1. How can I write the following code in easier way in Python ? if len(item['description']) 0: item['description'] =

[newbie questions] if conditions - if isset - if empty

2012-04-14 Thread Mahmoud Abdel-Fattah
Hello, I'm coming from PHP background ant totally new to Python, I just started using scrapy, but has some generic question in python. 1. How can I write the following code in easier way in Python ? if len(item['description']) 0: item['description'] = item['description'][0]

Re: [newbie questions] if conditions - if isset - if empty

2012-04-14 Thread Chris Angelico
On Sun, Apr 15, 2012 at 8:16 AM, Mahmoud Abdel-Fattah accou...@abdel-fattah.net wrote: Hello, I'm coming from PHP background ant totally new to Python, I just started using scrapy, but has some generic question in python. 1. How can I write the following code in easier way in Python ? if

Re: [newbie questions] if conditions - if isset - if empty

2012-04-14 Thread Zero Piraeus
: 1. How can I write the following code in easier way in Python ? if len(item['description']) 0:             item['description'] = item['description'][0]         else:             item['description'] = '' Assuming item['description'] is a string, all you need is item['description'] =

Re: [newbie questions] if conditions - if isset - if empty

2012-04-14 Thread Mahmoud Abdel-Fattah
Thanks ChrisA a lot. I just tried what you said, but I got an error, here's what I tried : item['name'] = hxs.select('//div[@id=center-main]/h1/text()').extract()[0] author_brand = re.match(r'^[.*] - (.*)$', item['name'], re.I|re.S|re.M) item['author_brand'] = author_brand.group(2) if

Re: [newbie questions] if conditions - if isset - if empty

2012-04-14 Thread Chris Angelico
On Sun, Apr 15, 2012 at 8:41 AM, Mahmoud Abdel-Fattah accou...@abdel-fattah.net wrote: item['author_brand'] = author_brand.group(2) if type(author_brand) != None else '' Almost there! :) None is a singleton, not a type; you don't need to check type(author_brand) but rather its identity. Use

Re: [newbie questions] if conditions - if isset - if empty

2012-04-14 Thread MRAB
On 14/04/2012 23:45, Chris Angelico wrote: On Sun, Apr 15, 2012 at 8:41 AM, Mahmoud Abdel-Fattah accou...@abdel-fattah.net wrote: item['author_brand'] = author_brand.group(2) if type(author_brand) != None else '' Almost there! :) None is a singleton, not a type; you don't need to check

Re: [newbie questions] if conditions - if isset - if empty

2012-04-14 Thread Chris Angelico
On Sun, Apr 15, 2012 at 9:00 AM, MRAB pyt...@mrabarnett.plus.com wrote: re.match(...) returns either a match object or None. In a condition, a match object always evaluates as True and None always evaluates as False. Yes, should have clarified that. It's a deliberate feature of the re module

Re: Many newbie questions regarding python

2010-10-11 Thread Jean-Michel Pichavant
Peter Pearson wrote: On Sat, 09 Oct 2010 19:30:16 -0700, Ethan Furman et...@stoneleaf.us wrote: Steven D'Aprano wrote: [snip] But that doesn't mean that the list comp is the general purpose solution. Consider the obvious use of the idiom: def func(arg, count): # Initialise

Re: Many newbie questions regarding python

2010-10-11 Thread Peter Pearson
On Sun, 10 Oct 2010 18:36:27 -0700, Ethan Furman et...@stoneleaf.us wrote: [snip] My question is more along the lines of: a mutable object was passed in to func()... what style of loop could be used to turn that one object into /n/ distinct objects? A list comp won't do it, but neither will

Re: Many newbie questions regarding python

2010-10-10 Thread Peter Pearson
On Sat, 09 Oct 2010 19:30:16 -0700, Ethan Furman et...@stoneleaf.us wrote: Steven D'Aprano wrote: [snip] But that doesn't mean that the list comp is the general purpose solution. Consider the obvious use of the idiom: def func(arg, count): # Initialise the list. L = [arg for i in

Re: Many newbie questions regarding python

2010-10-10 Thread Ethan Furman
Peter Pearson wrote: On Sat, 09 Oct 2010 19:30:16 -0700, Ethan Furman et...@stoneleaf.us wrote: Steven D'Aprano wrote: [snip] But that doesn't mean that the list comp is the general purpose solution. Consider the obvious use of the idiom: def func(arg, count): # Initialise the list.

Re: Many newbie questions regarding python

2010-10-09 Thread Steven D'Aprano
On Thu, 07 Oct 2010 18:34:58 -0700, alex23 wrote: On Oct 8, 10:27 am, Steven D'Aprano st...@remove-this- cybersource.com.au wrote:     v = [0 for i in range(20)] Absolutely not. Such a code snippet is very common, in fact I've done it myself, but it is a hammer solution -- to a small boy

Re: Many newbie questions regarding python

2010-10-09 Thread Hrvoje Niksic
alex23 wuwe...@gmail.com writes: If anything, I feel like the list comp version is the correct solution because of its reliability, whereas the multiplication form feels like either a lucky naive approach or relies on the reader to know the type of the initialising value and its mutability.

Re: Many newbie questions regarding python

2010-10-09 Thread Ethan Furman
Steven D'Aprano wrote: And how often do you have an list that you are creating where you don't know what items you have to initialise the list with? [snip] You are right to point out that the third case is a Python gotcha: [[]]*n doesn't behave as expected by the naive or inexperienced

Re: Many newbie questions regarding python

2010-10-08 Thread Jean-Michel Pichavant
Rogério Brito wrote: class C: f = 1 def g(self): return f I get an annoying message when I try to call the g method in an object of type C, telling me that there's no global symbol called f. If I make g return self.f instead, things work as expected, but the code loses some

Re: Many newbie questions regarding python

2010-10-08 Thread BartC
Rogério Brito rbr...@ime.usp.br wrote in message news:i8lk0n$g3...@speranza.aioe.org... My first try to write it in Python was something like this: v = [] for i in range(20): v[i] = 0 Unfortunately, this doesn't work, as I get an index out of bounds when trying to index the v list.

Re: Many newbie questions regarding python

2010-10-08 Thread Tim Harig
On 2010-10-08, BartC b...@freeuk.com wrote: Rogério Brito rbr...@ime.usp.br wrote in message news:i8lk0n$g3...@speranza.aioe.org... If possible, I would like to simply declare the list and fill it latter in my program, as lazily as possible (this happens notoriously when one is using a

Re: Many newbie questions regarding python

2010-10-08 Thread Grant Edwards
On 2010-10-07, Rog??rio Brito rbr...@ime.usp.br wrote: If possible, I would like to simply declare the list and fill it latter in my program, as lazily as possible (this happens notoriously when one is using a technique of programming called dynamic programming where initializing all

Re: Many newbie questions regarding python

2010-10-08 Thread Grant Edwards
On 2010-10-08, Grant Edwards inva...@invalid.invalid wrote: On 2010-10-07, Rog??rio Brito rbr...@ime.usp.br wrote: If possible, I would like to simply declare the list and fill it latter in my program, as lazily as possible (this happens notoriously when one is using a technique of

Re: Many newbie questions regarding python

2010-10-08 Thread Grant Edwards
On 2010-10-08, Grant Edwards inva...@invalid.invalid wrote: On 2010-10-08, Grant Edwards inva...@invalid.invalid wrote: On 2010-10-07, Rog??rio Brito rbr...@ime.usp.br wrote: If possible, I would like to simply declare the list and fill it latter in my program, as lazily as possible (this

Re: Many newbie questions regarding python

2010-10-08 Thread Emile van Sebille
On 10/8/2010 10:15 AM Grant Edwards said... Damn. I should give up and go golfing. +1 QOTW Emile -- http://mail.python.org/mailman/listinfo/python-list

Re: Many newbie questions regarding python

2010-10-08 Thread gregf...@gmail.com
On Oct 7, 6:10 pm, Rogério Brito rbr...@ime.usp.br wrote: Hi there. I am used to some languages like C, but I am just a complete newbie with Python and, while writing some small snippets, I had encountered some problems, with which I would sincerely appreciate any help, since I appreciate

Re: Many newbie questions regarding python

2010-10-08 Thread alex23
On Oct 8, 10:27 am, Steven D'Aprano st...@remove-this- cybersource.com.au wrote:     v = [0 for i in range(20)] Absolutely not. Such a code snippet is very common, in fact I've done it myself, but it is a hammer solution -- to a small boy with a hammer, everything looks like a nail that

Re: Many newbie questions regarding python

2010-10-08 Thread nn
On Oct 7, 7:10 pm, Rogério Brito rbr...@ime.usp.br wrote: Hi there. I am used to some languages like C, but I am just a complete newbie with Python and, while writing some small snippets, I had encountered some problems, with which I would sincerely appreciate any help, since I appreciate

Re: Many newbie questions regarding python

2010-10-08 Thread Andreas Waldenburger
On Thu, 7 Oct 2010 18:34:58 -0700 (PDT) alex23 wuwe...@gmail.com wrote: On Oct 8, 10:27 am, Steven D'Aprano st...@remove-this- cybersource.com.au wrote:     v = [0 for i in range(20)] Absolutely not. Such a code snippet is very common, in fact I've done it myself, but it is a hammer

Re: Many newbie questions regarding python

2010-10-08 Thread Carl Banks
On Oct 7, 4:10 pm, Rogério Brito rbr...@ime.usp.br wrote: [snip]     v = [0 for i in range(20)]     v = [0] * 20     v = []     for i in range(20): v.append(0) What should I prefer? Any other alternative? The Pythonic way is to not to preinitialize the list at all. Don't put anything in

Many newbie questions regarding python

2010-10-07 Thread Rogério Brito
Hi there. I am used to some languages like C, but I am just a complete newbie with Python and, while writing some small snippets, I had encountered some problems, with which I would sincerely appreciate any help, since I appreciate this language to write my running pseudocode in and I am

Re: Many newbie questions regarding python

2010-10-07 Thread MRAB
On 08/10/2010 00:10, Rogério Brito wrote: Hi there. I am used to some languages like C, but I am just a complete newbie with Python and, while writing some small snippets, I had encountered some problems, with which I would sincerely appreciate any help, since I appreciate this language to

Re: Many newbie questions regarding python

2010-10-07 Thread Andreas Waldenburger
On Thu, 07 Oct 2010 20:10:14 -0300 Rogério Brito rbr...@ime.usp.br wrote: I am used to some languages like C, but I am just a complete newbie with Python and, while writing some small snippets, I had encountered some problems, with which I would sincerely appreciate any help, since I

Re: Many newbie questions regarding python

2010-10-07 Thread Andreas Waldenburger
On Fri, 08 Oct 2010 00:46:41 +0100 MRAB pyt...@mrabarnett.plus.com wrote: In other words, don't try to write a C program in Python! Man, I'm good. :D /W -- To reach me via email, replace INVALID with the country code of my home country. But if you spam me, I'll be one sour kraut. --

Re: Many newbie questions regarding python

2010-10-07 Thread Tim Harig
On 2010-10-07, Rogério Brito rbr...@ime.usp.br wrote: 1 - The first issue that I am having is that I don't seem to be able to, say, use something that would be common for people writing programs in C: defining a one-dimensional vector and only initializing it when needed. For instance, in

Re: Many newbie questions regarding python

2010-10-07 Thread Steven D'Aprano
On Thu, 07 Oct 2010 20:10:14 -0300, Rogério Brito wrote: What is the Pythonic way of writing code like this? So far, I have found many alternatives and I would like to write code that others in the Python community would find natural to read. Some of the things that crossed my mind: v

Re: sqlite newbie questions

2007-06-26 Thread Carsten Haese
On Tue, 26 Jun 2007 08:38:29 GMT, Dennis Lee Bieber wrote: In both cases, the whole idea behind letting the adapter do parameter substitution is that the adapter will add the appropriate delimiters (quote marks, for the most part) needed for the data type. That's only the case if the

Re: sqlite newbie questions

2007-06-22 Thread [EMAIL PROTECTED]
On Jun 21, 11:54 am, Luis M. González [EMAIL PROTECTED] wrote: You need to learn sql if you want to deal with databases. Don't worry, it's very easy, and here is a very good resource to get you up and running in a few minutes:http://www.sqlcourse.com Good luck! Luis Thanks Luis, will check

sqlite newbie questions

2007-06-21 Thread [EMAIL PROTECTED]
Hello, I have a sqlite database table which has a table named Transmittal. Before inserting a new record into the database, i'd like to perform some checking. How do i select all records with certain value (say Smith) for a column (say Last_Name)? Knowing almost nothing about SQL, i just selected

Re: sqlite newbie questions

2007-06-21 Thread Carsten Haese
On Thu, 2007-06-21 at 19:24 +, [EMAIL PROTECTED] wrote: Hello, I have a sqlite database table which has a table named Transmittal. Before inserting a new record into the database, i'd like to perform some checking. How do i select all records with certain value (say Smith) for a column

Re: sqlite newbie questions

2007-06-21 Thread [EMAIL PROTECTED]
Thank you Carsten. Problem solved. -- http://mail.python.org/mailman/listinfo/python-list

Re: sqlite newbie questions

2007-06-21 Thread Luis M . González
On Jun 21, 4:24 pm, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Hello, I have a sqlite database table which has a table named Transmittal. Before inserting a new record into the database, i'd like to perform some checking. How do i select all records with certain value (say Smith) for a

Re: Some basic newbie questions...

2007-01-02 Thread Kent Johnson
jonathan.beckett wrote: I'm just finding it a bit weird that some of the built in functions are static, rather than methods of objects (such as len() being used to find the length of a list). Another explanation here:

Re: Some basic newbie questions...

2006-12-29 Thread Duncan Booth
jonathan.beckett [EMAIL PROTECTED] wrote: I'm just finding it a bit weird that some of the built in functions are static, rather than methods of objects (such as len() being used to find the length of a list). When it comes down to it, its a design decision, so neither right nor wrong in

Re: Some basic newbie questions...

2006-12-29 Thread Daniel Klein
On 28 Dec 2006 08:40:02 -0800, jonathan.beckett [EMAIL PROTECTED] wrote: Hi all, Question 2... What is the correct way of looping through a list object in a class via a method of it? Without peeking at any of the other responses, here is what I came up with. I hope it helps... class

Some basic newbie questions...

2006-12-28 Thread jonathan.beckett
Hi all, While working on support at work, I have been picking away at Python - because I think it could be a valuable scripting tool for building utilities from. I have been reading the python.org tutorials, and playing around with some basic code, but I have ended up with a few questions that

Re: Some basic newbie questions...

2006-12-28 Thread Grant Edwards
On 2006-12-28, jonathan.beckett [EMAIL PROTECTED] wrote: Hi all, While working on support at work, I have been picking away at Python - because I think it could be a valuable scripting tool for building utilities from. I have been reading the python.org tutorials, and playing around with

Re: Some basic newbie questions...

2006-12-28 Thread Chris Mellon
On 28 Dec 2006 08:40:02 -0800, jonathan.beckett [EMAIL PROTECTED] wrote: Hi all, While working on support at work, I have been picking away at Python - because I think it could be a valuable scripting tool for building utilities from. I have been reading the python.org tutorials, and playing

Re: Some basic newbie questions...

2006-12-28 Thread jonathan.beckett
Chris Mellon wrote: On 28 Dec 2006 08:40:02 -0800, jonathan.beckett [EMAIL PROTECTED] wrote: Hi all, While working on support at work, I have been picking away at Python - because I think it could be a valuable scripting tool for building utilities from. I have been reading the

Re: Some basic newbie questions...

2006-12-28 Thread jonathan.beckett
Hi Grant, thanks for the code snippets - made total sense. On the evidence of the last couple of hours, Python is still feeling very alien, but I'm starting to get my head around it. I'm just finding it a bit weird that some of the built in functions are static, rather than methods of objects

Re: Some basic newbie questions...

2006-12-28 Thread Grant Edwards
On 2006-12-28, jonathan.beckett [EMAIL PROTECTED] wrote: Given the code below, why does the count method return what it does? How *should* you call the count method? a = [] a.append(1) print a.count print a.count(). Which will cause an exception, BTW, since the count method

Re: Some basic newbie questions...

2006-12-28 Thread Grant Edwards
On 2006-12-28, jonathan.beckett [EMAIL PROTECTED] wrote: I'm just finding it a bit weird that some of the built in functions are static, rather than methods of objects (such as len() being used to find the length of a list). Well, they actually are methods of objects (at least they are now --

Re: Some basic newbie questions...

2006-12-28 Thread jonathan.beckett
I normally work with PHP, C#, Javascript, and the odd bit of C++, Do any of them call functions w/o parens? That's a really good point :) -- http://mail.python.org/mailman/listinfo/python-list

Re: Some basic newbie questions...

2006-12-28 Thread Scott David Daniels
jonathan.beckett wrote: Hi all, While working on support at work, I have been picking away at Python - because I think it could be a valuable scripting tool for building utilities from. I have been reading the python.org tutorials, and playing around with some basic code, but I have ended

Re: Some basic newbie questions...

2006-12-28 Thread jonathan.beckett
Too many misconceptions here (I changed to a more PEP-8 style naming): class Gun(object): def __init__(self): self.shells = 10 class Battleship(object): def __init__(self): self.guns = [Gun(), Gun()] def getShellsLeft(self):

Re: Some basic newbie questions...

2006-12-28 Thread Scott David Daniels
jonathan.beckett wrote: ... class Battleship(object): ... def getShellsLeft(self): numShells = 0 for aGun in self.guns: numShells += aGun.shells return numShells ... Excellent example - once upon a time I used to

Newbie questions for Python usage

2006-08-22 Thread Caolan
Hello, I am fairly new to Python and after exploring the language some I havesome questions: I understand HOW to use the lambda operator, but WHY would you want to use it? Can anyone please give an example of WHY you would need it as opposed to just declaring a function either in

Re: Newbie questions for Python usage

2006-08-22 Thread Fredrik Lundh
Caolan wrote: 1. I understand HOW to use the lambda operator, but WHY would you want to use it? Can anyone please give an example of WHY you would need it as opposed to just declaring a function either in the local scope, or outside? you don't *need* it, because

RE: Newbie questions for Python usage

2006-08-22 Thread Caolan
Title: Re: Newbie questions for Python usage Thanks Fred. just assign to the attribute and be done with it. if you want to use a placeholder value, use None: I thought I had tried that already but got an error. I'll try it again, and as for the 2nd one, I was hoping to avoid the usage

Re: Mega Newbie Questions: Probably FAQs

2006-08-16 Thread Peter Decker
On 8/15/06, Zeph [EMAIL PROTECTED] wrote: Framework for what kind of apps? Web, native GUI, client-server, etc? MVC is an abstract architecture rather than a specific implementation. Even so, many implementations rarely employ a purely MVC design. Native GUI with some client-server

Re: Mega Newbie Questions: Probably FAQs

2006-08-15 Thread Simon Forman
Zeph wrote: Python Pros: Free. Open source. Deep. Flexible. Rich community and third party stuff. Well documented. Cons: Interpreted. Unknown: Secure (meaning not easily reverse engineered) code? Performance? Very recent thread on this subject:

Mega Newbie Questions: Probably FAQs

2006-08-14 Thread Zeph
I'm pretty well of a mind to pick up Python. I like it because it seems to have a fair degree of functionality and is accessible to someone without a PhD in computer sciences. This is my second day of investigation, and I'm astounded by the huge ecosystem that surrounds it. I have a number of

Re: Mega Newbie Questions: Probably FAQs

2006-08-14 Thread AlbaClause
Zeph wrote: 4) There are a lot of books and tutorials out there, but they are of the proof-of-concept type. Specifically, a tutorial might teach me Hello World, but not really care about the framework, because it's a very simple item, and the point is simply to get me coding. I'd like to

Re: Mega Newbie Questions: Probably FAQs

2006-08-14 Thread ajaksu
Zeph wrote: 1) I want to write high-level apps that are db connected, networkable and cross-platform: Linux, Mac OSX, Windows. I know there are apps that can convert to Linux or Windows as stand-alone executables, is there also one that will permit me to convert to MacOSX? Yes, py2app

Re: Mega Newbie Questions: Probably FAQs

2006-08-14 Thread Zeph
ajaksu wrote: Hoping this helps more than confuses, Thanks, these were the sort of answers I was looking for. I've programmed in Basic, AppleScript, Pascal and Usertalk (Userland Frontier), I've got a sense for development, it's just been a very, very long time ago. I do intend to start

Re: Mega Newbie Questions: Probably FAQs

2006-08-14 Thread Zeph
ajaksu wrote: Zeph wrote: And I'd research a bit about decompiling those executables, might be easier (or harder, in my case) than you thought :) Are you saying that generally python code is insecure? It hadn't occurred to me, but I want to play in a fairly competitive field, and I'd hate to

Re: Mega Newbie Questions: Probably FAQs

2006-08-14 Thread AlbaClause
Zeph wrote: ajaksu wrote: I do intend to start small and build up, but I want to front load my learning curve, usually makes the other side of the curve more productive. Did you ever play on teeter-totters when you were a kid? I think that's what they're called. Those board like things

Re: Mega Newbie Questions: Probably FAQs

2006-08-14 Thread Yu-Xi Lim
Zeph wrote: 1b) Are these executable completely free from the need of the average user needing to install Python. Basically, I want to write and sell compiled apps. OSX and Linux installations nearly always come with Python pre-installed (usually because they are required by other system

Re: Mega Newbie Questions: Probably FAQs

2006-08-14 Thread Zeph
Zeph wrote: 3) Can someone recommend a good framework that will enable me to keep things well sorted out, and easy to maintain as my apps grow? (I'm considering MVC, but have no idea how to apply it until I've gone beyond Hello World). Yu-Xi Lim wrote: Framework for what kind of apps?

Re: OT: unix newbie questions

2006-06-06 Thread Fredrik Lundh
Carlos Lopez wrote: Please help i am losing my mind ... UNIX Newbee *23. How do you add a line to the end of an existing file myfile with date stamp. (1) * f = open(myfile, a+) f.write(datestamp) f.close() *24. Display recent 10 java files, (with *.java extension) , in descending

Re: OT: unix newbie questions

2006-06-06 Thread Fredrik Lundh
Fredrik Lundh wrote: *24. Display recent 10 java files, (with *.java extension) , in descending order by time, latest to oldest time. (1) * files = sorted(glob.glob(*.py), key=os.path.getmtime)[-10:] files.reverse() (to display the files, use print) /F --

Re: OT: unix newbie questions

2006-06-06 Thread Maric Michaud
Le Mardi 06 Juin 2006 08:36, Fredrik Lundh a écrit : *26. You observed that some of your group members are fiddling with your file  myfile and you wanted to remove the read permission to your group. How do you do? (1)   os.chmod(myfile.txt, 0404) rather, os.chmod(myfile.txt, 0400) I

OT: unix newbie questions

2006-06-05 Thread Carlos Lopez
Please help i am losing my mind ... UNIX Newbee 23. How do you add a line to the end of an existing file "myfile" with date stamp. (1) Ans : /home/clopez ed test.txt $a The last line of text. . w q 24. Display recent 10 java files, (with *.java extension) , in descending order by time,

Re: OT: unix newbie questions

2006-04-05 Thread Lawrence D'Oliveiro
In article [EMAIL PROTECTED], Gerard Flanagan [EMAIL PROTECTED] wrote: * To create an empty __init__.py file I do 'vim __init__.py' then immediately exit vim, is there a shell or vim command which will create an empty file without opening the editor? man touch * If I want to do :

Re: OT: unix newbie questions

2006-04-05 Thread flamesrock
Another option is zsh, which is very much like bash, but better ;) -- http://mail.python.org/mailman/listinfo/python-list

Re: OT: unix newbie questions

2006-03-27 Thread Inyeol Lee
On Sat, Mar 25, 2006 at 03:45:56AM -0800, Gerard Flanagan wrote: [...] * If I want to do : mv mypackage-1.0.2.tar.gz subdir/mypackage-1.0.2.tar.gz then tab-completion gives me the first occurrence of the file, but I have to type the second occurrence - is there a way of not

Re: OT: unix newbie questions

2006-03-26 Thread Joel Hedlund
* I'm using the tcsh shell and have no problems with it, but bash seems more popular - any reason to change? (I don't intend writing many shell scripts) You can do this in bash: $ python myprog stdout.txt 2 stderr.txt and have output to sys.stdout and sys.stderr go in separate files.

OT: unix newbie questions

2006-03-25 Thread Gerard Flanagan
Hello all Some basic unix questions which pure laziness prevents me from googling for. Anyone feeling charitable? I'm using FreeBSD 6.0: * To create an empty __init__.py file I do 'vim __init__.py' then immediately exit vim, is there a shell or vim command which will create an empty file

Re: OT: unix newbie questions

2006-03-25 Thread Rene Pijlman
Gerard Flanagan: * To create an empty __init__.py file I do 'vim __init__.py' then immediately exit vim, is there a shell or vim command which will create an empty file without opening the editor? touch __init__.py * cd ~ brings me to my home directory, is there a means by which I can set up a

Re: OT: unix newbie questions

2006-03-25 Thread Diez B. Roggisch
* If I want to do : mv mypackage-1.0.2.tar.gz subdir/mypackage-1.0.2.tar.gz then tab-completion gives me the first occurrence of the file, but I have to type the second occurrence - is there a way of not having to type it? No need to give it the name the second time. #

newbie questions

2006-03-15 Thread meeper34
Hi, I'm just starting out with Python, and so far I am thoroughly impressed with what you can do very easily with the language. I'm coming from a C++ background here. A couple of questions came up as I was thinking about dynamically typed languages: 1. If someone releases an interface in

  1   2   >