Hi Shi,
For what you're doing, nothing at all.
When you use a colon, slice syntax, it defaults to [start:end] so p =
a[:] is the same as
p = a[0:len(a)]
Regards,
Liam Clarke
On 11/11/05, Shi Mu <[EMAIL PROTECTED]> wrote:
> what is the difference between the two ways of assigning the list?
> p=
Johan Geldenhuys wrote:
> Hi all,
>
> What is the syntax if I want to work out what percentage 42 is out of 250?
>
42 is x percent of 250.
(is / of) = (x / 100)
one of those formulas from school I will always remember.
(42 / 250) = (x / 100.0)
250x = 4200.0
x = 4200.0 / 250
x = 16.8%
Liam Clarke schrieb:
>Hi Shi,
>
>For what you're doing, nothing at all.
>
>When you use a colon, slice syntax, it defaults to [start:end] so p =
>a[:] is the same as
>p = a[0:len(a)]
>
>
>
But in fact there is a difference. I'll show you:
>>> a=range(5)### creates a list-object
>>> id(a)
Oooh... that's a gotcha. Shi Mu - did you understand that? There is a
crucial difference as Gregor pointed out, that I missed, and I do
apologise.
On 11/11/05, Gregor Lingl <[EMAIL PROTECTED]> wrote:
> Liam Clarke schrieb:
>
> >Hi Shi,
> >
> >For what you're doing, nothing at all.
> >
> >When you
captnswing wrote:
> Hello all,
> I would like to log messages to a database (mysql)
> I found the example log_test14.py that comes with python logging
> module http://www.red-dove.com/python_logging.html
> but that example is a bit greek for me ... :) and it doesnt work with
> mysql
Have you u
> what is the difference between the two ways of assigning the list?
> p=a vs. p=a[:]
The first makes p point at the same list as a.
The second makes p point at a *copy* of the list pointed to by a.
You will see the difference if you try to modify the lists after assignment.
In the first case mod
Ah, memory lane time again :-)
>A good natured word of explanation for Chris and others:
> 10 FORN=1TO10:?N:NEXTN: REM It is bad form not to name N after NEXT to
> label which FOR NEXT loop is being incremented.
Oh, you had advanced BASIC - it allowed nested for loops! :-)
My first BASIC only al
thanks!
On 11/11/05, Gregor Lingl <[EMAIL PROTECTED]> wrote:
> Liam Clarke schrieb:
>
> >Hi Shi,
> >
> >For what you're doing, nothing at all.
> >
> >When you use a colon, slice syntax, it defaults to [start:end] so p =
> >a[:] is the same as
> >p = a[0:len(a)]
> >
> >
> >
> But in fact there is a
Kent Johnson wrote:
> Alex Hunsley wrote:
>>Where do you seasoned pythonites see unittest and doctest in relation to
>>each other? Do you only use one or the other?
>
>
> I think it is mostly personal preference. Doctest is nice where you
> create examples for others, maybe not so nice where you
All,
I have a dictionary say:
d = {'first':[]}
I am going through another list and depending on whats going on,
I want to add to the empty list. I have tried the following to noavail.
d['first'] = d['first'].append("string")
I would think this would result in the dictionary key first's empty list
On 11/11/05, Eric Walker <[EMAIL PROTECTED]> wrote:
> All,
> I have a dictionary say:
> d = {'first':[]}
> I am going through another list and depending on whats going on,
> I want to add to the empty list. I have tried the following to noavail.
>
> d['first'] = d['first'].append("string")
>
> I wo
You almost have it. Do this instead.
d = {'first':[]}
d['first'].append("string")
Append acts on the list, so assignment is unnecessary.
ds
Eric Walker wrote:
>All,
>I have a dictionary say:
>d = {'first':[]}
>I am going through another list and depending on whats going on,
>I want to add to t
ahh man,
I should have known. sheesh python is so kewl. I keep forgetting most times,
it will do stuff directly and you don't have to assign..
Thanks
Python Newbie
On Friday 11 November 2005 02:59 pm, DS wrote:
> You almost have it. Do this instead.
>
> d = {'first':[]}
> d['first'].appe
Rumor has it that Roger Merchberger may have mentioned these words:
>DirectFB is short for Direct Frame Buffer, and allows access to a graphical
>frame buffer system in *nix (and I think maybe MacOSX) from a text prompt
>without going through X.
>
>Anyone know of a module to access this through Pyt
Ah, memory lane time again :-)
Oh, you had advanced BASIC - it allowed nested for loops! :-)
My first BASIC only allowed for loops that could be written in a single
line...Anything more complex you had to call a subroutine with GOSUB.
Ha! Yes! As Monte Python would say, "Well..It got
Yes Johan, I did! Both the report and sort suggestions worked!
Thanks to everyone who replied!
FP
>From: Johan Geldenhuys <[EMAIL PROTECTED]>
>Reply-To: [EMAIL PROTECTED]
>To: CPIM Ronin <[EMAIL PROTECTED]>
>CC: tutor@python.org
>Subject: Re: [Tutor] simple report writing?
>Date: Fri, 11 Nov 2
> I should have known. sheesh python is so kewl. I keep forgetting most
> times,
> it will do stuff directly and you don't have to assign..
Whether thats 'kewl' depends on your viewpoint.
>From a pure computing point of view returning a value is more consistent
and correct in a functional program
Greetings:
I am writing the first of the handler routines for my test system web
interface. They will be Common Gateway Interface (CGI) scripts written in
Python. In the literature I have studied, I have seen the extensions .cgi
and .py applied to such files. Is one preferred over the other, or
The perl scripts use cgi.pm. The Python scripts use the cgi module.
Everything runs OK on Linux, where fork is available. On Windows the
run_cgi method uses os.popen3 to run the script and writes the post data
to the script's input file.
The Python scripts are OK. The Perl scripts do not receiv
There may be more than one way to have it get a zero value. But in
languages like Python readability and clarity are valued, and clearly
var = 0
is the clearest way to do it, although
var = var^var
comes to mind, *grin*
Hugo
Nathan Pinno wrote:
> Never mind all. I was just being stupid as u
20 matches
Mail list logo