This:
>>> dict(one=1,two=2,three=3)
{'three': 3, 'two': 2, 'one': 1}
Is a shortcut for the longer:
>>> dict((('one',1),('two',2),('three',3)))
{'three': 3, 'two': 2, 'one': 1}
and given how this works:
>>> def function(**kwargs):
... print kwargs
...
>>> function(one=1,two=2,three=3)
{'thre
On Wed, 2009-01-21 at 23:31 -0500, bob gailer wrote:
> Depends on your knowledge of Python and (if any) CMS Pipelines.
>
> Testing
> Design critique (devil's advocate)
> Cleaning up and fine-tuning the parser
> Coding built-in stages
> Documentation
> Financial support
>
> Let me know what spark
dict( [arg])
Return a new dictionary initialized from an optional positional argument or
from a set of keyword arguments. If no arguments are given, return a new empty
dictionary. If the positional argument arg is a mapping object, return a
dictionary mapping the same keys to the same values as
jadrifter wrote:
On Wed, 2009-01-21 at 22:53 -0500, bob gailer wrote:
Eric Dorsey wrote:
Does anyone know of any good volunteer opportunities for projects that
learning Python coders can work on? Or possibly nonprofits or the like
that need smaller-type applicatio
wormwood_3 wrote:
Hmm,
looked through the latest docs, in the sections on dictionary types,
don't see examples that point to this case well. Can you link to what
you had in mind?
2.1 Built-in Functions
...
dict( [mapping-or-sequence])
...
these all return a dictionary equal to {"on
Hmm, looked through the latest docs, in the sections on dictionary types, don't
see examples that point to this case well. Can you link to what you had in mind?
___
Samuel Huckins
Homepage - http://samuelhuckins.com
Tech blog - http://dancingpenguinsoflight.com/
Photos - ht
wormwood_3 wrote:
When
creating a list of dictionaries through a loop, I ran into a strange
issue. I'll let the code talk:
>>> l = 'i am a special new list'.split()
>>> t = []
>>> for thing in l:
... t.append({thing: 1})
...
>>> t
[{'i': 1}, {'am': 1}, {'a': 1}, {'special': 1}, {'
When creating a list of dictionaries through a loop, I ran into a strange
issue. I'll let the code talk:
>>> l = 'i am a special new list'.split()
>>> t = []
>>> for thing in l:
... t.append({thing: 1})
...
>>> t
[{'i': 1}, {'am': 1}, {'a': 1}, {'special': 1}, {'new': 1}, {'list': 1}]
This
Eric Dorsey wrote:
Does anyone know of any good volunteer opportunities for projects that
learning Python coders can work on? Or possibly nonprofits or the like
that need smaller-type applications worked on?
I have an open source project that could use some help. See
http://en.wikipedia.org
(My apologies if a blank message comes up first with this heading -- The
first time I meant to type this I managed to tab accidently to Send and hit
it before even filling out the message.. :/ )
Does anyone know of any good volunteer opportunities for projects that
learning Python coders can work
--
eric dorsey | www.perfecteyedesign.com
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
David wrote:
Thanks Bob,
I changed the wordlist.txt to
next
block
is
meat
and the program;
#!/usr/bin/python
password = 'loser'
wordlist = '/home/david/Challenge-You/wordlist.txt'
try:
words = open(wordlist, 'r').readlines()
except IOError, e:
print "Sorry no words"
for word in words:
#!/usr/bin/python
import re
password = 'loser'
wordlist = '/home/david/Challenge-You/wordlist.txt'
try:
words = open(wordlist, 'r').readlines()
except IOError, e:
print "Sorry no words"
for word in words:
word = word.replace("\n","")
if password in word:
print "The passwo
bob gailer wrote:
David wrote:
bob gailer wrote:
David wrote:
I have to ask for a pointer, not sure what I am doing wrong.
The first thing you are doing "wrong" is failing to tell us what is
in the wordlist file and what results you get when you run the program.
Please re-post with that i
"Robert Berman" wrote
Wow! That is all worth knowing. I am fascinated by the single sum
over a double loop.
> or more simply as a single sum over a double loop:
> bigtotal = sum(int(x) for line in myfile for x in line.split())
> which you may or may not see as an improvement...
And tha
David wrote:
bob gailer wrote:
David wrote:
I have to ask for a pointer, not sure what I am doing wrong.
The first thing you are doing "wrong" is failing to tell us what is
in the wordlist file and what results you get when you run the program.
Please re-post with that information.
#!/us
bob gailer wrote:
David wrote:
I have to ask for a pointer, not sure what I am doing wrong.
The first thing you are doing "wrong" is failing to tell us what is in
the wordlist file and what results you get when you run the program.
Please re-post with that information.
#!/usr/bin/python
p
David wrote:
I have to ask for a pointer, not sure what I am doing wrong.
The first thing you are doing "wrong" is failing to tell us what is in
the wordlist file and what results you get when you run the program.
Please re-post with that information.
#!/usr/bin/python
password = 'loser'
w
I have to ask for a pointer, not sure what I am doing wrong.
thanks
-david
#!/usr/bin/python
password = 'loser'
wordlist = '/home/david/Challenge-You/wordlist.txt'
try:
words = open(wordlist, 'r').readlines()
except IOError, e:
print "Sorry no words"
for word in words:
word = word.rep
Kent,
Wow! That is all worth knowing. I am fascinated by the single sum
over a double loop.
Thanks,
Robert Berman
Kent Johnson wrote:
On Wed, Jan 21, 2009 at 2:02 PM, Robert Berman wrote:
myfile = openinput()
for line in myfile:
jlist = line.split()
for x in
On Wed, Jan 21, 2009 at 2:02 PM, Robert Berman wrote:
> myfile = openinput()
> for line in myfile:
> jlist = line.split()
> for x in jlist:
> bigtotal += int(x)
Python has a sum() function that sums the elements of a numeric
sequence, so the inner loop can be written as
Alan,
Thank you for the clarification. Using that as my guide, I revamped my
solution to this small challenge and attempted to make the script as
concise as possible. The challenge is at the Challenge-You web page,
http://www.challenge-you.com/challenge?id=61
I am relatively certain I could h
ters, you could use a regular
expression:
import re
s = '1234 abc 5678 *** 1 233 xyz 476'
nums = [int (i) for i in re.findall ("\d+", s)] print nums
TJG
------
Message: 4
Date: Wed, 21 Jan 2009 08:50:29 -0500
From: Robert Berman
Subject: Re: [T
Am Tue, 20 Jan 2009 09:33:40 -0600
schrieb "Paul McGuire" :
No need for a defaultdict, all dicts have a setdefault method that
works fine for this assign an empty dict/list as starting point problem:
wordlendict = {}
for w in words:
wordlendict.setdefault(len(w), []).append(w)
try:
minle
Am Wed, 21 Jan 2009 05:40:00 -0800
schrieb jadrifter :
> >>>a = '1234 5678 1 233 476'
> >>>a.split()
> ['1234', '5678', '1', '233', '476']
[int(x) for x in a.split()] # [1234, 5678, 1, 233, 476]
Andreas
___
Tutor maillist - Tutor@python.org
http://mai
"Robert Berman" wrote
Perhaps i should not have said the most Python correct.
It looks as if it may well be the approach using the least
amount of work the interpreter must complete.
That's generally true. Python can always do things the long way but
its
generally more efficient both in pr
jadrifter wrote:
a = '1234 5678 1 233 476'
a.split()
['1234', '5678', '1', '233', '476']
Where the '>>>' are the command prompt from python. Don't type those.
A space is the default split delimiter. If you wish to use a '-' or new
line feed them as strings to the split method.
Ok, that's
Thanks to everyone who responded. Perhaps i should not
have said the most Python correct. It looks as if it may well be the
approach using the least amount of work the interpreter must complete.
At that point of speculation I am well out of my league.
I will be using the split method, and I t
Robert Berman wrote:
Given a string consisting of numbers separated by spaces such as '1234
5678 1 233 476'. I can see I have two obvious choices to extract or
parse out the numbers. The first relying on iteration so that as I
search for a blank, I build a substring of all characters found befo
>>>a = '1234 5678 1 233 476'
>>>a.split()
['1234', '5678', '1', '233', '476']
Where the '>>>' are the command prompt from python. Don't type those.
A space is the default split delimiter. If you wish to use a '-' or new
line feed them as strings to the split method.
John
On Wed, 2009-01-21 at
Good Morning,
Given a string consisting of numbers separated by spaces such as '1234
5678 1 233 476'. I can see I have two obvious choices to extract or
parse out the numbers. The first relying on iteration so that as I
search for a blank, I build a substring of all characters found before
th
31 matches
Mail list logo