On Mon, Oct 24, 2011 at 3:44 PM, bob gailer wrote:
> On 10/24/2011 7:45 AM, Wayne Werner wrote:
>
> On Sun, Oct 23, 2011 at 11:06 PM, Marc Tompkins
> wrote:
>
>> Things to remember:
>> -you can get a value from a method, but you can't assign to it:
>> variable = object.method()
>> but NOT
On Mon, Oct 24, 2011 at 9:20 PM, Chris Kavanagh wrote:
> Makes perfect sense now. . .Thanks again Marc (and Alan, Dave)
> BTW, do you guys luv Python the way I do!?? I just luv the way everything
> works together so explicitly. I LUV learning this stuff!!
>
Oh yeah, baby. Python makes programmi
On 10/24/2011 12:06 AM, Marc Tompkins wrote:
On Sun, Oct 23, 2011 at 8:08 PM, Chris Kavanagh mailto:cka...@msn.com>> wrote:
So we have {member.tell} as the last line of code. So trying to
understand this piece of code, {member} the variable is considered
an object? Therefore we can
On 25/10/11 00:02, Christopher King wrote:
Dear Tutors,
I am trying to make an object, which will appear exactly like an
object of my choice. It will should be impossible to tell it is not the
object.
We can get pretty close but I suspect its impossible to make it 100%
reliable - otherwis
On 24/10/11 20:52, Johan Martinez wrote:
Also, is there any doc link where I can find all the information about
String object - class and instance methods.
>>> help(str)
or even
>>> help("")
For a quick list try dir()
>>> dir ("")
Finally I figured it out ( __length__() ) thanks to ipy
On 24/10/11 19:00, Alan Gauld wrote:
For fun:
def getKeys(aDict, aValue):
return [key for key,val in aDict if val == aValue]
Oops, that should have been
return [key for key,val in aDict.items() if val == aValue]
--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me
Dear Tutors,
I am trying to make an object, which will appear exactly like an object
of my choice. It will should be impossible to tell it is not the object.
This is because I am making an object that modifies it methods so that if
the methods make a change to the object, it will sync those cha
Another approach is to subclass dict such that each time you add a
key:value pair you also create an entry in a reverse dictionary. Then
all you need do is lookup in the reverse dictionary.
If there are several keys with the same value, then create and extend a
list of values in the reverse di
On 10/24/2011 7:45 AM, Wayne Werner wrote:
On Sun, Oct 23, 2011 at 11:06 PM, Marc Tompkins
mailto:marc.tompk...@gmail.com>> wrote:
Things to remember:
-you can get a value from a method, but you can't assign to it:
variable = object.method()
but NOT
object.method() =
Hi Marc,
Thank you. Following some of your suggestion, the rewrite below worked. I agree with your point on readability over
complexity. By grace I meant not convoluted or simpler. That's all. As a beginner, I find not knowing all the
existing functions, I end up re-inventing the wheel som
nivedita datta wrote:
Hi all,
Can anyone tell me about some projects or applications which has been built
using pycrypto. Also I would like to know about any ongoing/past project or
application development in pycrypto.
This is a mailing list for beginners learning the basics of Python
program
the len() function works on lots of objects:
>>> a = "this is a string"
>>> len(a)
16
On Mon, Oct 24, 2011 at 3:52 PM, Johan Martinez wrote:
>
>
> On Mon, Oct 24, 2011 at 2:32 PM, Steve Willoughby wrote:
>
>> On 24-Oct-11 12:17, Johan Martinez wrote:
>>
>>> Thanks for the replies everyone - St
On Mon, Oct 24, 2011 at 2:32 PM, Steve Willoughby wrote:
> On 24-Oct-11 12:17, Johan Martinez wrote:
>
>> Thanks for the replies everyone - Steve, Dave, Sander and Wayne. I
>> realized my wrong understanding/interpretation after posting the message
>> to the list, which usually happens most of t
On 10/24/2011 03:21 PM, Johan Martinez wrote:
On Mon, Oct 24, 2011 at 2:07 PM, Andreas Perstinger<
andreas.perstin...@gmx.net> wrote:
On 2011-10-24 20:04, Johan Martinez wrote:
Hi,
I am struggling to understand Python string immutability. I am able to
modify Python string object after initi
On 24-Oct-11 12:17, Johan Martinez wrote:
Thanks for the replies everyone - Steve, Dave, Sander and Wayne. I
realized my wrong understanding/interpretation after posting the message
to the list, which usually happens most of the time with me!
That happens to most of us all the time too :) Unf
What you did here is just re-assigning s.
Try slicing s and then assign a new value to the slice.
s[2] would return 'r' now try to to set s[2] to another value to understand
immutability.
Hope it helps.
On 24 Oct 2011 19:06, "Johan Martinez" wrote:
> Hi,
>
> I am struggling to understand Python
On Mon, Oct 24, 2011 at 2:07 PM, Andreas Perstinger <
andreas.perstin...@gmx.net> wrote:
> On 2011-10-24 20:04, Johan Martinez wrote:
>
>> Hi,
>>
>> I am struggling to understand Python string immutability. I am able to
>> modify Python string object after initializing/assigning it a value.
>>
>>
On Mon, Oct 24, 2011 at 1:52 PM, Wayne Werner wrote:
> On Mon, Oct 24, 2011 at 1:04 PM, Johan Martinez wrote:
>
>> Hi,
>>
>> I am struggling to understand Python string immutability. I am able to
>> modify Python string object after initializing/assigning it a value. So how
>> does immutability wo
On 2011-10-24 20:04, Johan Martinez wrote:
Hi,
I am struggling to understand Python string immutability. I am able to
modify Python string object after initializing/assigning it a value.
s = "First"
print s.__class__
print s
First
s = "Second"
print s
Second
Dave, Sander and Wayne
On Mon, Oct 24, 2011 at 01:04:20PM -0500, Johan Martinez wrote:
> Hi,
>
> I am struggling to understand Python string immutability. I am able to
> modify Python string object after initializing/assigning it a value. So how
> does immutability work? I am not following it. Sorry for really stupid
>
On Mon, Oct 24, 2011 at 1:04 PM, Johan Martinez wrote:
> Hi,
>
> I am struggling to understand Python string immutability. I am able to
> modify Python string object after initializing/assigning it a value. So how
> does immutability work? I am not following it. Sorry for really stupid
> question
On Mon, 24 Oct 2011, 20:04:20 CEST, Johan Martinez wrote:
> I am struggling to understand Python string immutability. I am able to
> modify Python string object after initializing/assigning it a value. So
> how does immutability work? I am not following it. Sorry for really
> stupid question. Any
On 10/24/2011 02:04 PM, Johan Martinez wrote:
Hi,
I am struggling to understand Python string immutability. I am able to
modify Python string object after initializing/assigning it a value. So how
does immutability work? I am not following it. Sorry for really stupid
question. Any help?
You're c
On 24/10/11 14:18, Dave Angel wrote:
def getkey(dictionary, value):
for key, val in dictionary.items():
if val == value:
return key
Note that if there are multiple keys with the same value, my function
would get only the first. It wouldn't be hard to modify the function to
re
Hi,
I am struggling to understand Python string immutability. I am able to
modify Python string object after initializing/assigning it a value. So how
does immutability work? I am not following it. Sorry for really stupid
question. Any help?
>>> s = "First"
>>> print s.__class__
>>> print s
Fi
On 24/10/11 11:17, lina wrote:
a quick Q: Every time call the method, need go through the __initi__( ) part?
No.
__init__() is only called when an instance is first created.
Here is an example in the IDLE:
>>> class C:
def __init__(self):
print("I'm in init")
(You forgot to include the list on your reply. Easiest way is to do a
reply-all when you're replying)
On 10/24/2011 12:21 PM, Praveen Singh wrote:
On Mon, Oct 24, 2011 at 9:18 AM, Dave Angel wrote:
def getkey(dictionary, value):
for key, val in dictionary.items():
if va
On 10/24/2011 09:10 AM, Praveen Singh wrote:
In Dictionary-
How to print corresponding keys if the values of dictionary is given??
-d={'a':1,'b':2,'c':3}
-i can print the corresponding values by using get() method-
- d.get('a')
-1
What if i have to print reverse???
A dictionary can be viewed
Hi,
Keys are unique in a dictionaire but values aren't. What do you want to
print if you have the next dictionaire:
dict = {'a' : 1, 'b' : 1}
If you are using python 2.7 you can use dictionary comprehensions to swap
keys for values:
>>> d={'a':1,'b':2,'c':3}
>>> new_dict = {v : k for k,v in d.i
In Dictionary-
How to print corresponding keys if the values of dictionary is given??
-d={'a':1,'b':2,'c':3}
-i can print the corresponding values by using get() method-
- d.get('a')
-1
What if i have to print reverse???
___
Tutor maillist - Tutor@pyt
On Sun, Oct 23, 2011 at 11:06 PM, Marc Tompkins wrote:
> Things to remember:
> -you can get a value from a method, but you can't assign to it:
> variable = object.method()
> but NOT
> object.method() = variable
>
As a slight aside, you _can_ assign to the method name:
object.method = var
On 10/24/2011 4:40 AM, Alan Gauld wrote:
On 24/10/11 04:08, Chris Kavanagh wrote:
Thanks so much for the help Alan. . .I'm not trying to beat this
question into the ground, LOL, but let me see if I can ask it a better
way.
Marc has already given a good answer, but I'll try a slightly differ
a quick Q: Every time call the method, need go through the __initi__( ) part?
Thanks, I attached the one I used to practice fast-typing:
#!/usr/bin/python3
class SchoolMember:
'''Represents any school members.'''
def __init__(self,name,age):
self.name = name
self.age
On 24/10/11 04:08, Chris Kavanagh wrote:
Thanks so much for the help Alan. . .I'm not trying to beat this
question into the ground, LOL, but let me see if I can ask it a better way.
Marc has already given a good answer, but I'll try a slightly different
approach to the same thing The diff
On Mon, Oct 24, 2011 at 3:24 PM, Peter Otten <__pete...@web.de> wrote:
> lina wrote:
>
>> But I am getting confused later:
>>
>> def translate_process(dictionary,tobetranslatedfile):
>> results=[]
>> unique={}
>> for line in open(tobetranslatedfile,"r"):
>> tobetranslatedparts=l
>>
>> def translate_process(dictionary,tobetranslatedfile):
>> results=[]
>> unique={}
>> for line in open(tobetranslatedfile,"r"):
>> tobetranslatedparts=line.strip().split()
>> results.append(dictionary[tobetranslatedparts[2]])
>> unique=Counter(results)
>>
On Mon, Oct 24, 2011 at 3:24 PM, Peter Otten <__pete...@web.de> wrote:
> lina wrote:
>
>> But I am getting confused later:
>>
>> def translate_process(dictionary,tobetranslatedfile):
>> results=[]
>> unique={}
>> for line in open(tobetranslatedfile,"r"):
>> tobetranslatedparts=l
lina wrote:
> But I am getting confused later:
>
> def translate_process(dictionary,tobetranslatedfile):
> results=[]
> unique={}
> for line in open(tobetranslatedfile,"r"):
> tobetranslatedparts=line.strip().split()
> results.append(dictionary[tobetranslatedparts[2]])
38 matches
Mail list logo