Forwarding to the list.
-- Forwarded message --
From: Laureano Arcanio <[EMAIL PROTECTED]>
Date: Wed, May 21, 2008 at 10:41 PM
Subject: Re: [Tutor] listing classes
To: Kent Johnson <[EMAIL PROTECTED]>
I'm building a light html serialize tool, it's going to be used to
build templ
Faheem wrote:
Hi all,
How do I replace the same value multiple times without repeating the
same variable name/value repeatedly?
for ex.
some = 'thing'
print '%s %s %s %s' % (some,some,some,some)
in this case, my question is how do i replace "% (some,some,some)" with
something more concis
I don't know if this is the best solution, but what I usually do is
create a list that matches the key:
mydict = {}
mylist = []
for x in range(1, 10):
key = raw_input("Enter the key: ")
mydict[key] = value
mylist.append(key)
You just have to change it to read from a file/hard code all
On Wed, May 21, 2008 at 10:41 PM, Laureano Arcanio
<[EMAIL PROTECTED]> wrote:
> The problem comes because i need to keep the order of the HTML tags, and as
> you say dict doesn't work like that.. I've working on this metaclass, and
> then extend list with it, but i have the same problem, the dct c
Hello all,
I will be dealing with an address list where I might have the following:
Name SSN
John 1
John 1
Jane 2
Jill 3
What I need to do is parse the address list and then create a unique random
unidentifiable value for the SSN field like so:
Name SSNrandomvalu
On Thu, May 22, 2008 at 12:14 PM, GTXY20 <[EMAIL PROTECTED]> wrote:
> Hello all,
>
> I will be dealing with an address list where I might have the following:
>
> Name SSN
> John 1
> John 1
> Jane 2
> Jill 3
>
> What I need to do is parse the address list and then cre
Oops! Maybe it works better with reply to all:
You're looking for a completely random 9 digit number that you can't
derive the name from?
I don't know that anything would really be more or less secure than
simply using random.
>>> import random
>>> random.randrange(1,9)
988559585
On Thu, May 22, 2008 at 12:14 PM, GTXY20 <[EMAIL PROTECTED]> wrote:
> Hello all,
>
> I will be dealing with an address list where I might have the following:
>
> Name SSN
> John 1
> John 1
> Jane 2
> Jill 3
>
> What I need to do is parse the address list and then cre
On Thu, May 22, 2008 at 12:17 PM, taserian <[EMAIL PROTECTED]> wrote:
> so that I can relate it back to the original SSN when needed.
Oh! Oops! I didn't clearly understand this sentence the first time.
Yes, you want to learn about cryptography. Google for Bruce Schneier -
one of the world's forem
Thanks all;
Basically I will be given an address list of about 50 million address lines
- this will boil down to approximately 15 million unique people in the list
using SSN as the reference for the primary key. I was concerned that by
using random I would eventually have duplicate values for diff
On Thu, May 22, 2008 at 1:56 PM, GTXY20 <[EMAIL PROTECTED]> wrote:
> With respect to a potentially large dictionary object can you suggest
> efficient ways of handling memory when working with large dictionary
> objects?
Consider using a database. The public value can just be the primary
key of th
> > some = 'thing'
> > print '%s %s %s %s' % (some,some,some,some)
>
> You can use named parameters, which moves the repetition to the format string:
>
> In [24]: print '%(some)s %(some)s %(some)s %(some)s' % (dict(some=some))
> thing thing thing thing
>
> With multiple values, a common trick
Is there an equivalent to the C/C++ 'case' (or 'switch') statement in Python?
Dinesh
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
no, but you can
a) use elifs
if c==1:
do this
elif c==2:
do this
elif c==3:
do this
b) make a dictionary of functions (this is faster)
def case1: do this
def case2: do that
def case3: do the other
cases = {1: case2, 2: case2, 3:case3}
cases[c]()
if your functions are one expression you c
>
> cases = {
> 1: lambda: x*2
> 2: lambda: y**2
> 3: lambda: sys.stdout.write("hi\n")
> }
>
i forgot the commas.
cases = {
1: lambda: x*2,
2: lambda: y**2,
3: lambda: sys.stdout.write("hi\n")
}
>
> your functions and lambdas can also take parameters of course
>
lambda a, b: a*b
_
"Dinesh B Vadhia" <[EMAIL PROTECTED]> wrote
Is there an equivalent to the C/C++ 'case' (or 'switch') statement
in Python?
No, just if/elif
However you can often achieve similar results with a dictionary:
def func1(v): return v
def func2(v): return v*2
switch = { 'val1': func1,
Hey guys,
Very new to programming Python, and I'm running up against a problem. I am
building a program that will take a text file, search for a string in that
text file. Once it finds the string its looking for, I want to put the next
five lines of text into a variable. Here's what I have so far:
On 23/05/2008, Jason Conner <[EMAIL PROTECTED]> wrote:
Hi Jason,
> def loadItem(self, objectToLoad):
> x = 0
> wordList = []
> fobj = file()
> fobj.open("itemconfig.txt", 'rU')
>
> for line in fobj.readline():
In recent pythons, you can write this better as:
for line in fob
Hey All,
Thanks..
That was quick. Good to know there is a mailing list like this one.
Thanks to everyone and all the replies.
Faheem
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
19 matches
Mail list logo