I have an sqlite database as a source {Asset and Test data from a Megger
PAT Tester}, which contains a number of tables, and I end up with an
OpenOffice spreadsheet, with numerous sheets
The data is proceesed in three parts, each using a separate Class.
I extract the useful tables, and store
On 2018-08-14, Alan Gauld via Tutor wrote:
> - Use a list for objects(*) where you might need to
> change the value of one of the objects
A list is standard practice when you need an ordered collection
of objects of the same type, e.g., a bunch of numbers, a bunch of
chickens, etc.. It is most
On 14/08/18 07:56, Rafael Knuth wrote:
> List comprehension is really cool. One thing I like about list
> comprehension is that you can get a dictionary, tuples or lists as a
> result by just changing the type of braces.
>
> # dictionary
> colors = ["red", "blue", "white", "yellow"]
> colors_len
Use List comprehension:
animals = ["Dog", "Tiger", "SuperLion", "Cow", "Panda"]
animals_lol = [[animal, len(animal)] for animal in animals]
print(animals_lol)
[['Dog', 3], ['Tiger', 5], ['SuperLion', 9], ['Cow', 3], ['Panda', 5]]
If you want to read more about list comprehension,
> I wrote this code below
> I was wondering if there is a shorter, more elegant way to accomplish this
> task.
> Thanks!
thank you so much everyone!
List comprehension is really cool. One thing I like about list
comprehension is that you can get a dictionary, tuples or lists as a
result by just
On 2018-08-13, Rafael Knuth wrote:
> I wrote this code below which aims to concatenate strings with their
> respective string length. I was wondering if there is a
> shorter, more elegant way to accomplish this task. Thanks!
>
> animals = ["Dog", "Tiger", "SuperLion", "Cow", "Panda"]
You can
On 08/13/2018 09:53 AM, Rafael Knuth wrote:
> I wrote this code below which aims to concatenate strings with their
> respective string length.
did you mean concatenate? because you don't do any concatenation...
any time you hear keeping a data element with some information
associated, you should
On 13/08/18 16:53, Rafael Knuth wrote:
I wrote this code below which aims to concatenate strings with their
respective string length.
I was wondering if there is a shorter, more elegant way to accomplish this task.
Thanks!
animals = ["Dog", "Tiger", "SuperLion", "Cow", "Panda"]
# step one:
I wrote this code below which aims to concatenate strings with their
respective string length.
I was wondering if there is a shorter, more elegant way to accomplish this task.
Thanks!
animals = ["Dog", "Tiger", "SuperLion", "Cow", "Panda"]
# step one: convert the animal list into a list of lists
On 10/05/16 07:03, Ondřej Rusek wrote:
Dne 9.5.2016 v 10:13 Chris Roy-Smith napsal(a):
Hi
Python 3.4 Linux (ubuntu)
This code does what I want.
curs is the result of a mysql query
data = [[" " for x in range(9)] for y in range(count)]
for (ddate, mood, walk, lag, sleep) in curs:
On 10/05/16 12:01, Steven D'Aprano wrote:
On Mon, May 09, 2016 at 06:13:32PM +1000, Chris Roy-Smith wrote:
data = [[" " for x in range(9)] for y in range(count)]
for (ddate, mood, walk, lag, sleep) in curs:
data[row][0]=ddate
data[row][1]=mood
data[row][2]=walk
On Mon, May 09, 2016 at 06:13:32PM +1000, Chris Roy-Smith wrote:
> data = [[" " for x in range(9)] for y in range(count)]
> for (ddate, mood, walk, lag, sleep) in curs:
> data[row][0]=ddate
> data[row][1]=mood
> data[row][2]=walk
> data[row][3]=lag
>
On Mon, May 9, 2016 at 6:49 PM, Alan Gauld via Tutor wrote:
> On 09/05/16 22:03, Ondřej Rusek wrote:
>
>> but for 'tuples in list'... simple:
>>
>> data = []
>> for record in curs:
>>data += [record]
>
> Couldn't that be abbreviated to:
>
> date = list(curs)
>
I thought I
On 09/05/16 22:03, Ondřej Rusek wrote:
> but for 'tuples in list'... simple:
>
> data = []
> for record in curs:
>data += [record]
Couldn't that be abbreviated to:
date = list(curs)
--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
Dne 9.5.2016 v 10:13 Chris Roy-Smith napsal(a):
Hi
Python 3.4 Linux (ubuntu)
This code does what I want.
curs is the result of a mysql query
data = [[" " for x in range(9)] for y in range(count)]
for (ddate, mood, walk, lag, sleep) in curs:
data[row][0]=ddate
data[row][1]=mood
Chris Roy-Smith wrote:
> Hi
> Python 3.4 Linux (ubuntu)
>
> This code does what I want.
> curs is the result of a mysql query
>
>
> data = [[" " for x in range(9)] for y in range(count)]
> for (ddate, mood, walk, lag, sleep) in curs:
> data[row][0]=ddate
> data[row][1]=mood
>
On Mon, May 9, 2016 at 4:13 AM, Chris Roy-Smith
wrote:
> Hi
> Python 3.4 Linux (ubuntu)
>
> This code does what I want.
> curs is the result of a mysql query
>
>
does this work (untested)?
data = []
for stuff in curs:
data.append(stuff)
>
> While I
Hi
Python 3.4 Linux (ubuntu)
This code does what I want.
curs is the result of a mysql query
data = [[" " for x in range(9)] for y in range(count)]
for (ddate, mood, walk, lag, sleep) in curs:
data[row][0]=ddate
data[row][1]=mood
data[row][2]=walk
Hello,
I've been slowly teaching myself python, using it for small projects
when it seems appropriate. In this case, I was handed a list of email
addresses for a mailing but some of them had been truncated. There are
only 21 possible email suffixes so I planned to just identify which it
On Wed, Jan 11, 2012 at 7:34 AM, Marco Casazza marco.vince...@gmail.com wrote:
Hello,
I've been slowly teaching myself python, using it for small projects when it
seems appropriate. In this case, I was handed a list of email addresses for
a mailing but some of them had been truncated. There
On 2012-01-11 07:57, Joel Goldstick wrote:
On Wed, Jan 11, 2012 at 7:34 AM, Marco Casazzamarco.vince...@gmail.com wrote:
Hello,
I've been slowly teaching myself python, using it for small projects when it
seems appropriate. In this case, I was handed a list of email addresses for
a mailing
On Wed, Nov 30, 2011 at 8:46 PM, Dave Angel d...@davea.name wrote:
On 11/30/2011 07:49 PM, Steven D'Aprano wrote:
Norman Khine wrote:
hello,
is there a better way to organise this code or optimise it.
http://pastie.org/2944797
Is that a question? Because I get a syntax error in my
hi
On Thu, Dec 1, 2011 at 12:49 AM, Steven D'Aprano st...@pearwood.info wrote:
Norman Khine wrote:
hello,
is there a better way to organise this code or optimise it.
http://pastie.org/2944797
Is that a question? Because I get a syntax error in my brain when I parse it
without the
On 11/30/2011 8:46 PM, Dave Angel wrote:
On 11/30/2011 07:49 PM, Steven D'Aprano wrote:
Norman Khine wrote:
hello,
is there a better way to organise this code or optimise it.
http://pastie.org/2944797
I stopped looking at his pastie once the background turned black. I'd
have had to copy
hello,
is there a better way to organise this code or optimise it.
http://pastie.org/2944797
thanks
norman
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor
On Wed, Nov 30, 2011 at 3:34 PM, Norman Khine nor...@khine.net wrote:
hello,
is there a better way to organise this code or optimise it.
http://pastie.org/2944797
After glancing at it the only change that I would recommend (possibly)
making is lines 58 and 39 - you can wrap the
Norman Khine wrote:
hello,
is there a better way to organise this code or optimise it.
http://pastie.org/2944797
Is that a question? Because I get a syntax error in my brain when I parse it
without the question mark. wink
Sorry to pick on you, but it astonishes me when people don't bother
On 11/30/2011 07:49 PM, Steven D'Aprano wrote:
Norman Khine wrote:
hello,
is there a better way to organise this code or optimise it.
http://pastie.org/2944797
Is that a question? Because I get a syntax error in my brain when I
parse it without the question mark. wink
Sorry to pick on
In the following code I'm trying to do basic calculations with coulumb's law
#Coulombs Law
'''
F = (9*(10**9)) * (Q1*Q2) / (d**2)
'''
base = 10
Q1mult = raw_input('First enter multiplier of base 10 charge/coloumb(Q1):')
Q1exp = raw_input('Now enter exponent of base 10(Q1):')
Q1 =
On Mon, 3 May 2010 06:44:42 am David Hutto wrote:
In the following code I'm trying to do basic calculations with
coulumb's law
#Coulombs Law
'''
F = (9*(10**9)) * (Q1*Q2) / (d**2)
'''
base = 10
Q1mult = raw_input('First enter multiplier of base 10
charge/coloumb(Q1):') Q1exp =
On Sunday May 2 2010 22:44:42 David Hutto wrote:
Q1 and Q2 are to be entered as base ten scientific notation.
When I try to input Q1 as raw input, entering in ((2*(10**7)), I get:
ValueError: invalid literal for int() with base 10: '((2)*(10**7))'
Which is why I broke it down into it's
Better than this? http://py77.python.pastebin.com/fc7553a4
I've heard about BeautifulSoup.
http://www.crummy.com/software/BeautifulSoup/. Is it worth
learning? Is it crummy? ;-)
So 2 questions.
Thanks,
Dick Moores
___
Tutor maillist -
Here's one opinion, an answer to my second question.
Dick
Date: Fri, 25 Jul 2008 08:54:53 -0500
From: W W [EMAIL PROTECTED]
To: Dick Moores [EMAIL PROTECTED]
Subject: Re: [Tutor] Is there a better way to get a current mid-rate Yen
quote with Python?
Beautiful Soup is really awesome... I've used
Dick Moores [EMAIL PROTECTED] wrote
Here's one opinion, an answer to my second question.
Dick
And to answer your first: It depends on how you define better.
Certainly Beautiful Soup will not be muh longer and a lot more
elegant and probably more resilient.
But to extract a single piece
At 09:47 AM 7/25/2008, Alan Gauld wrote:
Dick Moores [EMAIL PROTECTED] wrote
Here's one opinion, an answer to my second question.
Dick
And to answer your first: It depends on how you define better.
Certainly Beautiful Soup will not be muh longer and a lot more
elegant and probably more
Dick Moores [EMAIL PROTECTED] wrote
Certainly Beautiful Soup will not be muh longer and a lot more
elegant and probably more resilient.
Alan, expand a bit, please. Longer? Resilient?
Longer as in lines of code. BS is good for extracting several
different parts from the soup, but just to
At 04:11 PM 7/25/2008, Alan Gauld wrote:
Dick Moores [EMAIL PROTECTED] wrote
Certainly Beautiful Soup will not be muh longer and a lot more
elegant and probably more resilient.
Alan, expand a bit, please. Longer? Resilient?
Longer as in lines of code. BS is good for extracting several
Date: Fri, 25 Jul 2008 05:14:32 -0700
From: Dick Moores [EMAIL PROTECTED]
Subject: [Tutor] Is there a better way to get a current mid-rate Yen
quote with Python?
To: Python Tutor List tutor@python.org
Message-ID: [EMAIL PROTECTED]
Content-Type: text/plain; charset=us-ascii; format
This is a second... the first one never hit the list. *shrug* should i be using a different interface to post? is this a gateway to newsgroup?I am writing my first python program(at least in a really long time).
Its purpose is to take csv or pipe delimintaed files and convert them
to html pages.
I am trying to do the usual thing of asking for an input and then checking
it to see if it is valid. If the entry is not valid then ask again until
you get the correct answer.
I have come up with this class. I am trying to make a transition from
procedural programming to object oriented. Is
John,
In this case I think using a class is overkill. You can write a simple
procedural version like this:
def getOption():
while True:
print
Please choose from the following options.
1) - Normal Unit test with static data.
2) - Normal Unit test with missing
41 matches
Mail list logo