Re: [Tutor] Code to download credit card statement and add to DB

2018-04-20 Thread Kuan Lu
Hello Mr. Tutor: I constructed a pieced of code utilizing requests and pyodbc to download creditcard statement transactions and insert them into a DB table based on the code published by Louis Millette here: https://github.com/louismillette/Banking/tree/master. Now I am a total newbie to Pytho

Re: [Tutor] Code to download credit card statement and add to DB

2018-04-20 Thread Kuan Lu
Hello Mr. Tutor: I constructed a pieced of code utilizing requests and pyodbc to download creditcard statement transactions and insert them into a DB table based on the code published by Louis Millette here: https://github.com/louismillette/Banking/tree/master. Now I am a total newbie to Pytho

Re: [Tutor] Code

2017-12-20 Thread Steven D'Aprano
On Tue, Dec 19, 2017 at 07:22:50PM -0500, Vinay Rao wrote: > Hi, > > We need help coding the range formula, and we don’t really know how to > do it. This is the formula, R=(V2Sin2theangle)/(g). We are trying to > solve for the angle. That's not a Python problem, that's a basic algebra problem.

Re: [Tutor] Code

2017-12-19 Thread boB Stepp
Welcome to Tutor! We won't do your homework for you, but will help you if you get stuck. Normally you would show us your current best coding effort and we would help you from there. On Tue, Dec 19, 2017 at 6:22 PM, Vinay Rao wrote: > Hi, > > We need help coding the range formula, and we don’t re

Re: [Tutor] Code not working advise pls

2016-11-04 Thread Cameron Simpson
On 04Nov2016 21:57, tracey jones-Francis wrote: I want to write a function that will calculate and return the sum of the n highest value in a list a. Also, when n is less than 0, the answer should be zero, and if n is greater than the number of elements in the list, all elements should be incl

Re: [Tutor] Code for python game

2016-10-12 Thread Derry, James R
hi, tracey, are you allowed to use python sets? if so, you should take a look at them and their methods: https://docs.python.org/3.5/tutorial/datastructures.html?highlight=data%20structures#sets best, james From: Tutor [tutor-bounces+jderry=mail.utexas...

Re: [Tutor] Code for python game

2016-10-12 Thread Alan Gauld via Tutor
On 12/10/16 18:40, tracey jones-Francis wrote: > I want to have a function that will ignore certain words that > i have specified in a dictionary. > the dictionary is called skip_words and has about 20 different strings in. We shouldn't care inside the function what the external data is called,

Re: [Tutor] Code wont run

2016-04-16 Thread Alan Gauld
On 09/04/16 10:32, Nevina Dias via Tutor wrote: Sorry for the delay the message was in the moderation queue and I was on holiday. As to your code it has not been posted in plain text so its been scrambled by the email system. We can't begin to decipher it. When you say it "won't run", do you get

Re: [Tutor] Code Problem

2016-03-10 Thread Alan Gauld
On 10/03/16 20:30, Ben Conklin wrote: > show if it is a equilateral, isosceles, or right triangle. I have it so > that it makes s1 the longest side, and s2 and s3 the other 2 sides. The > right triangle equation should be right, but is not outputting anything. The easiest way to find that is just

Re: [Tutor] Code Regress

2016-02-01 Thread boB Stepp
On Mon, Feb 1, 2016 at 8:22 AM, Evan Sommer wrote: > I tried the code suggestion that you proposed in december, and while > it did count down time, it actually set me back in a way because the > display is not how I desired it to be. I think you need to review all of Alan's previous suggestions.

Re: [Tutor] Code critique

2014-10-25 Thread Crush
Thank you Peter for your example. I have the code working now and will post soon for eveyones benefit. Thank you all who took the time to help. Bo ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.pyt

Re: [Tutor] Code critique

2014-10-25 Thread Peter Otten
Bo Morris wrote: > Thank you all for the helpful criticism. I wish I was able to catch on to > what you are suggesting more quickly. > > Based on your recommendations, I have come up with the following so far, > however I just dont see it as easily as I did while using the if/elif > statements. >

Re: [Tutor] Code critique

2014-10-24 Thread Bo Morris
Thank you all for the helpful criticism. I wish I was able to catch on to what you are suggesting more quickly. Based on your recommendations, I have come up with the following so far, however I just dont see it as easily as I did while using the if/elif statements. This is what I have so far. I

Re: [Tutor] Code critique

2014-10-24 Thread Japhy Bartlett
out = stdout.read() if '3102EHD-Lanka-1108' in out: s.exec_command('export DISPLAY=:0.0; cd /Downloads/Hourly/win.sh') sftp = s.open_sftp() sftp.get('/Downloads/Hourly/3102EHD-01108/3102EHD-01108.png', '/Downloads/Hourly/3102EHD-01108.png') sftp.close() print

Re: [Tutor] Code critique

2014-10-24 Thread Peter Otten
Bo Morris wrote: > "...Regarding your program, instead of writing long sequences of > repetitive if > conditions, I would write one function for each of the different > operations and store them in a dict, mapping each host name to a function > (and multiple host names may map to the same function

Re: [Tutor] Code critique

2014-10-24 Thread Bo Morris
"...Regarding your program, instead of writing long sequences of repetitive if conditions, I would write one function for each of the different operations and store them in a dict, mapping each host name to a function (and multiple host names may map to the same function). Then, look up the host na

Re: [Tutor] Code critique

2014-10-24 Thread Stefan Behnel
Bo Morris schrieb am 24.10.2014 um 14:03: > May I please get a little instructional criticism. The code below works. It > logs into 9 different Linux computers, runs a couple commands, and then > transfers a file back to the server. I want to become a better Python > coder; therefore, I was hoping

Re: [Tutor] code help

2014-09-29 Thread Alan Gauld
On 22/09/14 16:16, itsthewendigo . wrote: from tkinter import* master = Tk(); canvas = Canvas(master, width = simpledialog.askinteger("Canvas size", "Enter width of canvas")) Its generally a bad idea to mix interactivity with widget creation. Better(and much easier to debug) to query the

Re: [Tutor] code review

2014-06-13 Thread Adam Gold
On 12/06/14 00:38, Alan Gauld wrote: > > HTH Thanks Alan and Lukáš for your very helpful comments. I will attempt to revise the script in light of them and will revert if I hit any brick walls :) ___ Tutor maillist - Tutor@python.org To unsubscribe

Re: [Tutor] code review

2014-06-12 Thread Cameron Simpson
On 13Jun2014 12:28, Cameron Simpson wrote: snap_path = os.path.join(VXGEN_DIR, snapName) backupList.append(snap_name) Sorry, "snap_path" in both lines:-( Cheers, Cameron Simpson ___ Tutor maillist - Tutor@python.org To unsubscribe or change sub

Re: [Tutor] code review

2014-06-12 Thread Cameron Simpson
On 12Jun2014 00:38, Alan Gauld wrote: On 11/06/14 11:43, Adam Gold wrote: # create snapshot names like the following: 2014-06-10T01-00-01.vm1.img.bz2 for i in vgxenList: DATE = datetime.datetime.now().strftime("%Y-%m-%d" + "T" + "%H-%M-%S") Why use addition? You could just insett the lite

Re: [Tutor] code review

2014-06-11 Thread Alan Gauld
On 11/06/14 11:43, Adam Gold wrote: # create snapshot names like the following: 2014-06-10T01-00-01.vm1.img.bz2 for i in vgxenList: DATE = datetime.datetime.now().strftime("%Y-%m-%d" + "T" + "%H-%M-%S") Why use addition? You could just insett the literal T... DATE = datetime.datetime.now

Re: [Tutor] code review

2014-06-11 Thread Lukáš Němec
Ok, not so bad, hoewer there are some parts of the code that could be done a bit cleaner. I'll write them below in the response. Thanks for the reply Steven. It's no more than 100 lines at a guess In that case just copy and paste it into a message and send it to the group. Anyone with time av

Re: [Tutor] code review

2014-06-11 Thread Adam Gold
>>> Thanks for the reply Steven. It's no more than 100 lines at a >>> guess > >> In that case just copy and paste it into a message and send it to >> the group. Anyone with time available can then take a peek. > > One way noobs anywhere can learn is by listening in to other people's > conversati

Re: [Tutor] code review

2014-06-11 Thread Bob Williams
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 11/06/14 08:11, Alan Gauld wrote: > On 11/06/14 00:30, Adam Gold wrote: > >> Thanks for the reply Steven. It's no more than 100 lines at a >> guess > > In that case just copy and paste it into a message and send it to > the group. Anyone with tim

Re: [Tutor] code review

2014-06-11 Thread Alan Gauld
On 11/06/14 00:30, Adam Gold wrote: Thanks for the reply Steven. It's no more than 100 lines at a guess In that case just copy and paste it into a message and send it to the group. Anyone with time available can then take a peek. hth -- Alan G Author of the Learn to Program web site http:

Re: [Tutor] code review

2014-06-11 Thread Adam Gold
On 11/06/14 00:04, Steven D'Aprano wrote: > On Tue, Jun 10, 2014 at 04:51:20PM +0100, Adam Gold wrote: >> Hi there. I've been writing a script that is now finished and working >> (thanks, in part, to some helpful input from this board). What I'd >> really like to do now is go through it with an '

Re: [Tutor] code review

2014-06-10 Thread Lukas Nemec
Post it somewhere on github and I'll try to take a look at it. Lukas On 06/10/2014 05:51 PM, Adam Gold wrote: Hi there. I've been writing a script that is now finished and working (thanks, in part, to some helpful input from this board). What I'd really like to do now is go through it with an

Re: [Tutor] code review

2014-06-10 Thread Steven D'Aprano
On Tue, Jun 10, 2014 at 04:51:20PM +0100, Adam Gold wrote: > Hi there. I've been writing a script that is now finished and working > (thanks, in part, to some helpful input from this board). What I'd > really like to do now is go through it with an 'expert' who can point > out ways I may have bee

Re: [Tutor] Code runs in interpreter but won't output to stdout

2014-02-01 Thread scurvy scott
Please always reply to the tutor list so we can all play with your question. --sorry about that Bob, I've now hit reply all. I am stuck at "import requests". Where did you get that module? --requests is a third party webscraping module. I signed up at Dogehouse. What the heck is it? There is no

Re: [Tutor] Code runs in interpreter but won't output to stdout

2014-02-01 Thread Walter Prins
Hi Bob, On 31 January 2014 21:59, bob gailer wrote: > On 1/29/2014 8:59 PM, scurvy scott wrote: > I signed up at Dogehouse. What the heck is it? There is no explanation as to > what it does or what I'd do with it! I don't know if you're familiar with BitCoin and the concept of the "pooled mining

Re: [Tutor] Code runs in interpreter but won't output to stdout

2014-01-31 Thread bob gailer
On 1/29/2014 8:59 PM, scurvy scott wrote: Please always reply to the tutor list so we can all play with your question. On 1/28/2014 9:12 PM, scurvy scott wrote: Hi guys, I'm trying to figure out why my code won't output to terminal, but will run just fine in interpreter. I'm using

Re: [Tutor] Code runs in interpreter but won't output to stdout

2014-01-29 Thread bob gailer
On 1/28/2014 9:12 PM, scurvy scott wrote: Hi guys, I'm trying to figure out why my code won't output to terminal, but will run just fine in interpreter. I'm using python 2.7.3 on Debian Linux/Crunchbang. Here is my code. import requests from bs4 import BeautifulSoup as beautiful import sys de

Re: [Tutor] code works in windows command but not ubuntu terminal

2014-01-25 Thread spir
On 01/26/2014 02:12 AM, Steven D'Aprano wrote: On Sat, Jan 25, 2014 at 09:11:56AM +0100, spir wrote: As a foreigner, I noticed that english native speakers use both the series round / square / curly / angle brackets, and individual terms parens (no 'd' ;-) / brackets / braces / chevrons. No maj

Re: [Tutor] code works in windows command but not ubuntu terminal

2014-01-25 Thread Mark Lawrence
On 26/01/2014 01:55, Steven D'Aprano wrote: This is an international forum, and English an international language with many slight differences between variations and dialects. Even in American English alone, there are ambiguous terms. "Coke" could mean a beverage by the Coca-Cola company, a gene

Re: [Tutor] code works in windows command but not ubuntu terminal

2014-01-25 Thread Steven D'Aprano
On Sat, Jan 25, 2014 at 02:39:11PM -0500, bob gailer wrote: > On 1/24/2014 10:28 PM, bob gailer wrote: > > Sorry for misspelling parens. > > My reason for requesting the various names is that it makes > communication clear, explicit and terse. > > When someone says just "brackets" what does he

Re: [Tutor] code works in windows command but not ubuntu terminal

2014-01-25 Thread Steven D'Aprano
On Sat, Jan 25, 2014 at 09:11:56AM +0100, spir wrote: > As a foreigner, I noticed that english native speakers use both the series > round / square / curly / angle brackets, and individual terms parens (no > 'd' ;-) / brackets / braces / chevrons. No major issue, except for > 'brackets' which c

Re: [Tutor] code works in windows command but not ubuntu terminal

2014-01-25 Thread Alan Gauld
On 25/01/14 19:39, bob gailer wrote: On 1/24/2014 10:28 PM, bob gailer wrote: Sorry for misspelling parens. My reason for requesting the various names is that it makes communication clear, explicit and terse. When someone says just "brackets" what does he actually mean? In UK English speakin

Re: [Tutor] code works in windows command but not ubuntu terminal

2014-01-25 Thread bob gailer
On 1/24/2014 10:28 PM, bob gailer wrote: Sorry for misspelling parens. My reason for requesting the various names is that it makes communication clear, explicit and terse. When someone says just "brackets" what does he actually mean? For more grins see http://www.codinghorror.com/blog/2008/

Re: [Tutor] code works in windows command but not ubuntu terminal

2014-01-25 Thread Mark Lawrence
On 25/01/2014 03:28, bob gailer wrote: And please call () parends and [] brackets, and{} braces. Saves a lot of confusion. Not in the UK or Australia, with the former being where English came from. -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for o

Re: [Tutor] code works in windows command but not ubuntu terminal

2014-01-25 Thread spir
On 01/25/2014 05:14 AM, Steven D'Aprano wrote: On Fri, Jan 24, 2014 at 10:28:09PM -0500, bob gailer wrote: And please call () parends and [] brackets, and{} braces. Saves a lot of confusion. If you think that parentheses are spelt with a "d", you're certainly confused :-) They're all bracket

Re: [Tutor] code works in windows command but not ubuntu terminal

2014-01-24 Thread eryksun
On Fri, Jan 24, 2014 at 8:38 PM, Steven D'Aprano wrote: > > However, there's more to it than this. For starters, you need to decide > on the exact behaviour. Clearly, "file not found" errors should move on > to try the next prefix in the path list. But what about permission > denied errors? Prior

Re: [Tutor] code works in windows command but not ubuntu terminal

2014-01-24 Thread Steven D'Aprano
On Fri, Jan 24, 2014 at 10:28:09PM -0500, bob gailer wrote: > And please call () parends and [] brackets, and{} braces. Saves a lot of > confusion. If you think that parentheses are spelt with a "d", you're certainly confused :-) They're all brackets. Often the type of bracket doesn't matter,

Re: [Tutor] code works in windows command but not ubuntu terminal

2014-01-24 Thread bob gailer
On 1/24/2014 4:47 AM, Steven D'Aprano wrote: Hi Tobias, and welcome. On Thu, Jan 23, 2014 at 07:34:18PM -0700, Tobias Quezada wrote: hello community,i am a newbie to python and program in general. the script below works in python 2.7.3 on windows but not in the python 2.7.3 ubuntu terminal.

Re: [Tutor] code works in windows command but not ubuntu terminal

2014-01-24 Thread Steven D'Aprano
On Fri, Jan 24, 2014 at 04:31:49PM -0500, Keith Winston wrote: > On Fri, Jan 24, 2014 at 4:50 AM, Steven D'Aprano wrote: > > Python does not use a search path for the open() function, only for > > imports. With open(), it uses a simple rule: > > > > - absolute paths will look only in that exact lo

Re: [Tutor] code works in windows command but not ubuntu terminal

2014-01-24 Thread Danny Yoo
> Ah! I was just running into this... I did not know that. So there's no > way to get it to search a path (other than coding some string > concatenation of path names or something, of course) to open a file? Potentially distutils.spawn.find_executable might apply, http://docs.python.org/2/dis

Re: [Tutor] code works in windows command but not ubuntu terminal

2014-01-24 Thread Keith Winston
On Fri, Jan 24, 2014 at 4:50 AM, Steven D'Aprano wrote: > Python does not use a search path for the open() function, only for > imports. With open(), it uses a simple rule: > > - absolute paths will look only in that exact location; > > - relative paths are always relative to the current working d

Re: [Tutor] code works in windows command but not ubuntu terminal

2014-01-24 Thread Alan Gauld
On 24/01/14 02:34, Tobias Quezada wrote: >>>fp=open("prez.dat","r") >>>x=fp.read >>>(print(x) /IOError: [Errno 2] No such file or directory: 'prez.dat'/ Python can't see your file. You can check what python is seeing by importing os and using listdir(): import os os.listdir(',') # . is

Re: [Tutor] code works in windows command but not ubuntu terminal

2014-01-24 Thread maxin...@gmail.com
hello community,i am a newbie to python and program in general. the script below works in python 2.7.3 on windows but not in the python 2.7.3 ubuntu terminal. >>>fp=open("prez.dat","r")>>>x=fp.read>>>(print(x)***i used fp for file >>>pointer.I am using windows 7 and it works but on ubuntu 12.04

Re: [Tutor] code works in windows command but not ubuntu terminal

2014-01-24 Thread Steven D'Aprano
On Fri, Jan 24, 2014 at 04:22:20AM -0500, Keith Winston wrote: > The file would appear to not be on your search path, that is, in any > directory in which Python is expecting to find it. Python does not use a search path for the open() function, only for imports. With open(), it uses a simple rul

Re: [Tutor] code works in windows command but not ubuntu terminal

2014-01-24 Thread Steven D'Aprano
Hi Tobias, and welcome. On Thu, Jan 23, 2014 at 07:34:18PM -0700, Tobias Quezada wrote: > hello community,i am a newbie to python and program in general. > the script below works in python 2.7.3 on windows but not in the python 2.7.3 > ubuntu terminal. > > >>> fp=open("prez.dat","r") > >>> x=fp.

Re: [Tutor] code works in windows command but not ubuntu terminal

2014-01-24 Thread Peter Otten
Tobias Quezada wrote: > hello community,i am a newbie to python and program in general. > the script below works in python 2.7.3 on windows but not in the python > 2.7.3 ubuntu terminal. > fp=open("prez.dat","r")>>>x=fp.read>>>(print(x)***i used fp for file pointer.I am using windows 7 an

Re: [Tutor] code works in windows command but not ubuntu terminal

2014-01-24 Thread Keith Winston
I should have mentioned, the other possibility is that the file does not, in fact, exist, but I assume you put it out there somewhere? ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/l

Re: [Tutor] code works in windows command but not ubuntu terminal

2014-01-24 Thread Keith Winston
The file would appear to not be on your search path, that is, in any directory in which Python is expecting to find it. Either move it to a directory on your path, or change your path to include it's location. The easiest way to find out what your path is, that I know, is import sys sys.path Good

Re: [Tutor] code smells: Object-orientation Abusers: switch statements

2014-01-04 Thread Danny Yoo
Compare: ### class Dog(object): pass class Cat(object): pass class Cow(object): pass def sayHi(animal): if isinstance(animal, Dog): print("Woof") elif isinstance(animal, Cat): print("Meow") elif isinstance(animal, Cow):

Re: [Tutor] code smells: Object-orientation Abusers: switch statements

2014-01-04 Thread Alan Gauld
I meant to add... On 04/01/14 20:47, Alan Gauld wrote: Its called polymorphism and is one of the most powerful advantages of OOP since case or switch statements are one of the most fault prone structures in procedural programming. ... Without OOP you would need to do something like for shape i

Re: [Tutor] code smells: Object-orientation Abusers: switch statements

2014-01-04 Thread Alan Gauld
On 04/01/14 20:11, Alex Kleider wrote: Assuming I am correct that in Python, switch statements must be implemented as a series of if; elif; .. statements, how is it that this can be avoided by creating subclasses? Its called polymorphism and is one of the most powerful advantages of OOP sinc

Re: [Tutor] Code to open a website

2013-02-11 Thread Alan Gauld
On 11/02/13 01:14, Steven D'Aprano wrote: exit() and quit() (as added by the site.py module) are for interactive use. aha! They're mostly there for the benefit of newbies. Experienced developers (at least in the Unix/Linux world) usually know to exit interactive terminal apps with Ctrl-D. I

Re: [Tutor] Code to open a website

2013-02-10 Thread Steven D'Aprano
On 10/02/13 20:25, ALAN GAULD wrote: Maybe the OP meant to say 'quit()' ? That does not require an import. Ooh! another option I didn't know about! So many ways to get rid of Python and here's me been importing sys or raising SystemExit all these years... :-) exit() and quit() (as added

Re: [Tutor] Code to open a website

2013-02-10 Thread eryksun
On Sun, Feb 10, 2013 at 3:39 AM, ALAN GAULD wrote: > So it does. You learn something new every day... > When did that first happen? It was one of my biggest frustrations > with Python when I first started learning, that you couldn't call exit > without first importing sys (v1.3). But I never notic

Re: [Tutor] Code to open a website

2013-02-10 Thread Peter Otten
ALAN GAULD wrote: >> Maybe the OP meant to say 'quit()' ? That does not require an import. > > > Ooh! another option I didn't know about! > So many ways to get rid of Python and here's me been importing sys > or raising SystemExit all these years... :-) I tend to use none of these and my script

Re: [Tutor] Code to open a website

2013-02-10 Thread ALAN GAULD
> Maybe the OP meant to say 'quit()' ? That does not require an import. Ooh! another option I didn't know about! So many ways to get rid of Python and here's me been importing sys  or raising SystemExit all these years... :-) Alan G. ___ Tutor mailli

Re: [Tutor] Code to open a website

2013-02-10 Thread Albert-Jan Roskam
> On Sat, Feb 9, 2013 at 8:33 PM, Alan Gauld > wrote: >> >> Where does exit() come from? Usually its from sys but you >> don't import from sys anywhere... > > site.py adds the exit/quit Quitter instances to builtins (2.x > __builtin__). When called they raise SystemExit, like sys.exit does

Re: [Tutor] Code to open a website

2013-02-10 Thread ALAN GAULD
>site.py adds the exit/quit Quitter instances to builtins (2.x >__builtin__). When called they raise SystemExit, like sys.exit does. So it does. You learn something new every day... When did that first happen? It was one of my biggest frustrations  with Python when I first started learning, that

Re: [Tutor] Code to open a website

2013-02-09 Thread mann kann
oh wow, I foolishly named it webbrowser.py earlier. Thanks for the witty hint, Danny :) On Sat, Feb 9, 2013 at 11:55 PM, Danny Yoo wrote: > On Sat, Feb 9, 2013 at 6:25 PM, mann kann wrote: > > I used webbrowser and it worked via terminal, but the same code returns > > AttrituteError: 'module'

Re: [Tutor] Code to open a website

2013-02-09 Thread Danny Yoo
On Sat, Feb 9, 2013 at 6:25 PM, mann kann wrote: > I used webbrowser and it worked via terminal, but the same code returns > AttrituteError: 'module' object has no attribute 'open' in komodo edit. > suggestions? here's the code: > > import webbrowser > webbrowser.open("http://youtube.com";) What

Re: [Tutor] Code to open a website

2013-02-09 Thread eryksun
On Sat, Feb 9, 2013 at 8:33 PM, Alan Gauld wrote: > > Where does exit() come from? Usually its from sys but you > don't import from sys anywhere... site.py adds the exit/quit Quitter instances to builtins (2.x __builtin__). When called they raise SystemExit, like sys.exit does. Since you can bypa

Re: [Tutor] Code to open a website

2013-02-09 Thread Alan Gauld
On 10/02/13 01:00, mann kann wrote: Dear Jedi, I wrote my first program but it doesn't open a website as I intended it to. Please correct my mistake. Well, how did you intend it to? It looks like it probably does open the web site, but it will be hard to tell since you do nothing with the res

Re: [Tutor] Code to open a website

2013-02-09 Thread mann kann
I used webbrowser and it worked via terminal, but the same code returns AttrituteError: 'module' object has no attribute 'open' in komodo edit. suggestions? here's the code: import webbrowser webbrowser.open("http://youtube.com";) On Sat, Feb 9, 2013 at 8:17 PM, Wayne Werner wrote: > On Sat,

Re: [Tutor] Code to open a website

2013-02-09 Thread Wayne Werner
On Sat, 9 Feb 2013, mann kann wrote: Dear Jedi,  I wrote my first program but it doesn't open a website as I intended it to. Please correct my mistake.  Sincerely,  Mann You'll actually want the webbrowser module, which will open the links in your web browser - at least if you want to load s

Re: [Tutor] code to generate my own text captchas

2012-10-25 Thread Alan Gauld
On 24/10/12 22:05, Tsila Hassine wrote: Hello all, I am looking for simple python code that will take a given string and distort it, captcha like. it is for artistic purposes, so no verification required. I just need the image q text distortion code. A Google search for 'python captcha generato

Re: [Tutor] code to generate my own text captchas

2012-10-24 Thread Steven D'Aprano
On 25/10/12 08:05, Tsila Hassine wrote: Hello all, I am looking for simple python code that will take a given string and distort it, captcha like. You won't find any such simple code, because distorting images is not simple. This is a mailing list for learning how to program in the Python prog

Re: [Tutor] code to generate my own text captchas

2012-10-24 Thread Modulok
On 10/24/12, Tsila Hassine wrote: > Hello all, > I am looking for simple python code that will take a given string and > distort it, captcha like. it is for artistic purposes, so no verification > required. I just need the image q text distortion code. > Thanks!!! > tsila You might look into writ

Re: [Tutor] code to generate my own text captchas

2012-10-24 Thread Mark Lawrence
On 24/10/2012 22:05, Tsila Hassine wrote: Hello all, I am looking for simple python code that will take a given string and distort it, captcha like. it is for artistic purposes, so no verification required. I just need the image q text distortion code. Thanks!!! tsila I'll send you some code i

Re: [Tutor] Code Review?

2012-08-07 Thread Tino Dai
On Mon, Aug 6, 2012 at 6:27 PM, Brian Carpio wrote: > Thanks to everyone who has replied! This is some good information for me > to go learn with!. > > I greatly appreciate it. > > When you refactor your code, let us know. I, for one, would like to see it.

Re: [Tutor] Code Review?

2012-08-06 Thread Brian Carpio
Thanks to everyone who has replied! This is some good information for me to go learn with!. I greatly appreciate it. Brian On Mon, Aug 6, 2012 at 9:21 AM, Peter Otten <__pete...@web.de> wrote: > Brian Carpio wrote: > > > Hi, > > > > Hopefully I am allowed to ask this here. I am pretty new to py

Re: [Tutor] Code Review?

2012-08-06 Thread Peter Otten
Brian Carpio wrote: > Hi, > > Hopefully I am allowed to ask this here. I am pretty new to python I've > only been writing code for about 6 months now strictly for system > administration purposes; however I have now decided to write something > "real" that others might benefit from but I am looki

Re: [Tutor] Code Review?

2012-08-06 Thread Mark Lawrence
On 06/08/2012 14:38, Ramchandra Apte wrote: [top posting fixed] On 6 August 2012 18:59, Brian Carpio wrote: Hi, Hopefully I am allowed to ask this here. I am pretty new to python I've only been writing code for about 6 months now strictly for system administration purposes; however I have n

Re: [Tutor] Code Review?

2012-08-06 Thread Tino Dai
On Mon, Aug 6, 2012 at 9:39 AM, Ramchandra Apte wrote: > Another practice is make __license__ = "GPL license..." > and __author__ = "Brian Carpio " > I do so. > > > On 6 August 2012 19:08, Ramchandra Apte wrote: > >> In scripts/add_node.py GPL Licene should be GPL License >> >> >> Brian, I

Re: [Tutor] Code Review?

2012-08-06 Thread Ramchandra Apte
In scripts/add_node.py GPL Licene should be GPL License On 6 August 2012 18:59, Brian Carpio wrote: > Hi, > > Hopefully I am allowed to ask this here. I am pretty new to python I've > only been writing code for about 6 months now strictly for system > administration purposes; however I have now

Re: [Tutor] Code Review?

2012-08-06 Thread Ramchandra Apte
Another practice is make __license__ = "GPL license..." and __author__ = "Brian Carpio " I do so. On 6 August 2012 19:08, Ramchandra Apte wrote: > In scripts/add_node.py GPL Licene should be GPL License > > On 6 August 2012 18:59, Brian Carpio wrote: > >> Hi, >> >> Hopefully I am allowed to ask

Re: [Tutor] Code structure help

2011-03-11 Thread mdekauwe
(...snip...) I think your question is appropriate for both lists, it just wasn't sexy enough for anyone on c.l.py to answer ;) what is not sexy about modelling plant carbon uptake ;P Random remarks: > pg = PlantGrowth(self.control, self.params, self.state, >

Re: [Tutor] Code structure help

2011-03-11 Thread Peter Otten
Martin De Kauwe wrote: > Note I have cross posted this as I have only just found this mailing list > and perhaps it is the more appropriate place (I am not sure)? I think your question is appropriate for both lists, it just wasn't sexy enough for anyone on c.l.py to answer ;) > I have been wor

Re: [Tutor] Code evaluation inside of string fails with __get_item

2010-12-12 Thread David Hutto
On Sun, Dec 12, 2010 at 2:42 PM, Tim Johnson wrote: > * Steven D'Aprano [101211 17:20]: >> Tim Johnson wrote: >> >>>   I've never had the occasion to use assert() or any other >>>   python - shooting tools, any thoughts on that? >> >> >> Assertions are a great tool, but never ever, under pain of

Re: [Tutor] Code evaluation inside of string fails with __get_item

2010-12-12 Thread Tim Johnson
* Steven D'Aprano [101211 17:20]: > Tim Johnson wrote: > >> I've never had the occasion to use assert() or any other >> python - shooting tools, any thoughts on that? > > > Assertions are a great tool, but never ever, under pain of great pain, > use assert for testing user input or function

Re: [Tutor] Code evaluation inside of string fails with __get_item

2010-12-11 Thread Steven D'Aprano
Tim Johnson wrote: I've never had the occasion to use assert() or any other python - shooting tools, any thoughts on that? Assertions are a great tool, but never ever, under pain of great pain, use assert for testing user input or function arguments. It's tempting to knock up a quick a

Re: [Tutor] Code evaluation inside of string fails with __get_item

2010-12-11 Thread Tim Johnson
* Peter Otten <__pete...@web.de> [101211 03:41]: > (1) the method is spelt __getitem__ (two leading and two trailing > underscores) > > (2) the left side is a python string with legal "%(...)s"-style format > expressions. Given a format string > > s = "%(s.upper())s" > > try to feed it a real

Re: [Tutor] Code evaluation inside of string fails with __get_item

2010-12-11 Thread Peter Otten
Tim Johnson wrote: > This is a resend. I note that the original had an incorrect > `reply-to' ID attached to it. (sorry) > -- > I'm using Python 2.6.5. > The following problem is coming from inside of a complex code base > and involve

Re: [Tutor] code quest

2010-11-20 Thread Alan Gauld
"Kirk Bailey" wrote OK, I need to create or find a function that will return a list of DIRECTORIES (only) which are under 'the current directory'. Anyone got some clue on this? Please advise. You can use os.walk() to get a list of directories and files and then just throw away the files...

Re: [Tutor] code quest

2010-11-20 Thread Emile van Sebille
On 11/20/2010 11:03 AM Kirk Bailey said... OK, I need to create or find a function that will return a list of DIRECTORIES (only) which are under 'the current directory'. Anyone got some clue on this? Please advise. Use os.walk Emile Help on function walk in module os: walk(top, topdown=T

Re: [Tutor] Code review, plase

2010-09-08 Thread Alex
On Wed, Sep 8, 2010 at 12:20 AM, Steven D'Aprano wrote: > On Wed, 8 Sep 2010 06:39:27 am Alex wrote: >> Hi all. >> >> Could someone review my code? It's the first time I develop a >> reusable module and I would like to have some feedback. >> If you think it's good enough I will package it for pypi

Re: [Tutor] Code review, plase

2010-09-07 Thread Steven D'Aprano
On Wed, 8 Sep 2010 06:39:27 am Alex wrote: > Hi all. > > Could someone review my code? It's the first time I develop a > reusable module and I would like to have some feedback. > If you think it's good enough I will package it for pypi. > > I put the code on pastebin: http://pastebin.com/Tz367gAM

Re: [Tutor] Code review, plase

2010-09-07 Thread Wayne Werner
On Tue, Sep 7, 2010 at 3:39 PM, Alex wrote: > Hi all. > > Could someone review my code? It's the first time I develop a reusable > module and I would like to have some feedback. > If you think it's good enough I will package it for pypi. > > I put the code on pastebin: http://pastebin.com/Tz367gA

Re: [Tutor] code improvement

2009-09-29 Thread Patrick Sabin
You could invert your if-expressions, e.g. instead of if query_company_name: ... you could write if not query_company_name: return adresses, company ... This way you could save some indentation. If you want to get rid of the for loops, you could look at list comprehensions, e

Re: [Tutor] code improvement

2009-09-25 Thread Kent Johnson
On Fri, Sep 25, 2009 at 1:00 AM, Norman Khine wrote: >>> Is there a better method to write the last bit of the code. > Apologies for not being clear. I was thinking more  that I may have > one the too many 'for' loops at the end of the code. > > http://paste.lisp.org/display/87659#1 It's only t

Re: [Tutor] code improvement

2009-09-24 Thread Norman Khine
On Thu, Sep 24, 2009 at 10:25 PM, Kent Johnson wrote: > On Thu, Sep 24, 2009 at 2:12 PM, Norman Khine wrote: >> Hello, >> I have this function in my class: >> >> http://paste.lisp.org/display/87659 >> >> Is there a better method to write the last bit of the code. > > Better in what way? What are

Re: [Tutor] code improvement

2009-09-24 Thread Kent Johnson
On Thu, Sep 24, 2009 at 2:12 PM, Norman Khine wrote: > Hello, > I have this function in my class: > > http://paste.lisp.org/display/87659 > > Is there a better method to write the last bit of the code. Better in what way? What are these things? What is resource? Some context would be helpful, I s

Re: [Tutor] code structure terminology and advice

2009-07-22 Thread Che M
> To: tutor@python.org > From: alan.ga...@btinternet.com > Date: Wed, 22 Jul 2009 08:46:04 +0100 > Subject: Re: [Tutor] code structure terminology and advice > > > "Che M" wrote > > You pretty much answered your own question. > > The ultima

Re: [Tutor] code structure terminology and advice

2009-07-22 Thread Glen Zangirolami
Che, You should check out the python styling guide here. It give examples about how to write python code. PEP 8 -- Style Guide for Python Code Hope this helps! ___ Tutor maillist - Tutor@python.org http://mai

Re: [Tutor] code structure terminology and advice

2009-07-22 Thread Alan Gauld
"Che M" wrote You pretty much answered your own question. The ultimate answer depends on a few other contextual issues. Q1) Generally, what is the best structure for when there are a number of steps/actions that need to be taken? A sequence! :-) Q2) Is there a term/some jargon in prog

  1   2   >