> > What's the most "pythonic" way to make this work?
>
> class BaseClass(object):
> def __init__(self, x, y, z, foo='foo'): # whatever
> # etc
>
> class SubClass(BaseClass):
> def __init__(self, t, *args, **kw):
> BaseClass.__init__(self, *args, **kw)
> # do something with t
>
> > class MySubClass(MySuperClass):
> >
> > def __init__(self, just_a_sub_option): # what about other args? **args?
>
> I think I would go ahead and list the superclass parameters and put the
> new one at the end:
> def __init__(self, opt_1, opt_2, opt_3, opt_n, just_a_sub_option):
>
Nowadays the best practice for invoking a method from all superclasses
(yes, multiple inheritance) is this:
class SubClass(BaseClass):
def __init__(self, t, *args, **kw):
super(SubClass, self).__init__(*args, **kw)
# do something with t
That way you let Python decide which sup
I actually said "ending" to avoid problems with different terminology
between different languages - but i guess a return is still a return in
python.
i did this search
http://www.google.ca/search?hl=en&q=python+tutorial+return&btnG=Google+Search&meta=
and it didn't return any particularly obviou
Oh i am good with range then, because it's not a real time program.
On Tue, Mar 18, 2008 at 3:55 PM, Shrutarshi Basu <[EMAIL PROTECTED]>
wrote:
> I'm not entirely sure about this, but I think for range(), the entire
> range of numbers is generated at one go, which could cause a
> slow-down. But
Allen Fowler wrote:
> What's the most "pythonic" way to make this work?
>
> class MySuperClass(object):
>
> def __init__(self, opt_1, opt_2, opt_3, opt_n):
># stuff done here
> pass
>
>
> class MySubClass(MySuperClass):
>
> def __init__(self, just_a_sub_option)
"elis aeris" <[EMAIL PROTECTED]> wrote
> how do I return a function?
>
Do you realise that this is an entirely different question
to the one you asked originally, namely:
>> what do I do if i want the program/function to end?
>>
>> in c++ of
>>int main(){}
>>I do a return 0;
One is asking about
"Kent Johnson" <[EMAIL PROTECTED]> wrote
>> Add a 3rd step-value argument to range. (You don't need the xrange
>> on modern versions of Python BTW)
>
> Only if by 'modern' you mean Python 3; on Python 2.x there is a
> difference between range() and xrange(). Though for a list of 20
> ints I
> do
On 19/03/2008, Allen Fowler <[EMAIL PROTECTED]> wrote:
> Hello,
>
> What's the best way convert keyword arguments to object properties?
You can mess around with self.__dict__.update(kwargs) or
update(locals()). I'm not sure exactly what you want to do..
See this recipe: http://aspn.activestate.
On 19/03/2008, Allen Fowler <[EMAIL PROTECTED]> wrote:
> I have a super class that accepts many arguments to it's constructor, and a
> subclass that should define one additional argument.
>
> What's the most "pythonic" way to make this work?
class BaseClass(object):
def __init__(self, x, y, z
Hello,
What's the best way convert keyword arguments to object properties?
Basically, I have a defined list of valid object properties that I'd like to
optionally specify in the call to the constructor.
I've got ideas about using __getattr__ but I'm not sure if that's the right
way. Plus, tha
Hello,
Now, perhaps this not the best way write code, but I have a few questions
regrading calling the super classes constructor:
I have a super class that accepts many arguments to it's constructor, and a
subclass that should define one additional argument.
What's the most "pythonic" way to m
Guba ha scritto:
> I was unable to find information on tuple(). (The Python help function
> was rather conservative in its output, Google not helpful).
> What exactly is the use of tuple(q) here, and why does not a simple q
> instead of tuple(q) do? The latter would have been my intuitive
> expect
[EMAIL PROTECTED] wrote: Welcome to the Tutor@python.org mailing list! This
list is for folks
who want to ask (and/or answer) questions from folks who wish to learn
how to program with Python. Feel free to ask even the most basic of
questions -- that's what the list is for!
For best results wh
I'm not entirely sure about this, but I think for range(), the entire
range of numbers is generated at one go, which could cause a
slow-down. But xrange() generates the list of numbers one at a time.
For a thousand, there shouldn't be much of a difference, but if you
need a million or so go with xr
elis aeris wrote:
> I seriously have done my homework on writing in python
I wonder if I am misunderstanding your question. This is a simple
question about how functions work in Python, right? Something that most
every beginning tutorial covers? You wouldn't be asking here if you had
done you
i was reading it the second time 6months after and in fact i am working on
version 3 of it with update to functionality.
(and yes, it is MY code)
how do I return a function?
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo
ok i need about 500~1000
is that ok?
my pet practice works works fine with it,but what should I watch out for?
sorry for double reply kent, forgot to reply all.
On Tue, Mar 18, 2008 at 3:21 PM, Kent Johnson <[EMAIL PROTECTED]> wrote:
> Alan Gauld wrote:
>
> > Add a 3rd step-value argument to r
Alan Gauld wrote:
> Add a 3rd step-value argument to range. (You don't need the xrange
> on modern versions of Python BTW)
Only if by 'modern' you mean Python 3; on Python 2.x there is a
difference between range() and xrange(). Though for a list of 20 ints I
don't think it matters much.
Kent
_
"elis aeris" <[EMAIL PROTECTED]> wrote
> what do I do if i want the program/function to end?
>
> in c++ of
>
> int main(){}
>
> I do a return 0;
Actually you don;t. In your e4xample yuou just have empty
braces and that will end just fine! Similarly in Python it will
just silently drop off
ok.
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
"elis aeris" <[EMAIL PROTECTED]> wrote
> for x in xrange (20, 0):
>print x
>
> this doesn't work because it goes from a big number to a small
> number, which
> does nothing
> but what if I need the for loop to go from a big number to a small
> number?
Add a 3rd step-value argument to range
"TFIA Consulting, Inc." <[EMAIL PROTECTED]> wrote
> Your site says it should take just a "few days" to learn Python,
Thats true if you are talking about the core language
and a few of the most common libraries - sys, re, os,
and maybe 1 or 2 more. But thats not iincluding the
hundred or so other
and also, I didn't need to break function is that program, to which i am
amazed of, now come to think of it.
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
CCing the list.
Please use Reply All when responding.
> I am still little confused since I was under the impression,
> that if a c program was able to write this binary code,
> then if we know how c "packed" the data/string then
> we able to decode/unpack it using python.
Thats correct but y
elis aeris wrote:
> what do I do if i want the program/function to end?
>
>
> in c++ of
>
> int main(){}
>
> I do a return 0;
What have you tried in Python? How did it work and what didn't work the
way you expected? What Python documentation or tutorials have you read?
Maybe helpful:
http:/
I looked at the Miro gig too. Good luck!
As far as "learn python in 12 days", yes and no.
You can do fantastic things in that time frame with python and the
standard library. I know I had completely written my first code
analysis program in 2004 in that time frame just using this PDF as
reference
what do I do if i want the program/function to end?
in c++ of
int main(){}
I do a return 0;
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
elis aeris wrote:
> for x in xrange (20, 0):
> print x
> but what if I need the for loop to go from a big number to a small number?
Just give a step value:
for x in xrange(20, 0, -1):
print x
Kent
___
Tutor maillist - Tutor@python.org
http://
x = 0
y = 0
for x in xrange (20, 0):
print x
this doesn't work because it goes from a big number to a small number, which
does nothing
but what if I need the for loop to go from a big number to a small number?
___
Tutor maillist - Tutor@python
TFIA Consulting, Inc. wrote:
> Hi. I am doing some work for a company that uses Python for their
> application.
> I have never used Python before, but I have programmed for over 35
> years, maybe 12 languages including 4 assembly level.
> Your site says it should take just a "few days" to learn
i am not sure if I am still in the mailing list of tutor@python.org so
please use reply all to send me a email directly please!
x = 0
y = 0
for x in xrange (20, 0):
print x
this doesn't work because it goes from a big number to a small number, which
does nothing
but what if I need the
Hi. I am doing some work for a company that uses Python for their application.
I have never used Python before, but I have programmed for over 35 years, maybe
12 languages including 4 assembly level.
Your site says it should take just a "few days" to learn Python, so I told
these folks to give
PyProg PyProg wrote:
> Hello,
>
> I have a little problem, I have two lists:
>
a=[1, 2, 3, 4, 5, 6]
b=['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j']
>
> ... and I want to obtain:
>
[('a', 1), ('b', 2), ('c', 3), ('d', 4), ('e', 5), ('f', 6), ('g',
> 1), ('h', 2), ('i', 3), ('
Assuming that len(b) > len(a):
>>> zip(itertools.cycle(a), b)
[(1, 'a'), (2, 'b'), (3, 'c'), (4, 'd'), (5, 'e'), (6, 'f'), (1, 'g'), (2,
'h'), (3, 'i'), (4, 'j')]
Andreas
Am Dienstag, den 18.03.2008, 16:23 +0100 schrieb PyProg PyProg:
> Hello,
>
> I have a little problem, I have two lists:
>
Hello,
I have a little problem, I have two lists:
>>> a=[1, 2, 3, 4, 5, 6]
>>> b=['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j']
... and I want to obtain:
>>> [('a', 1), ('b', 2), ('c', 3), ('d', 4), ('e', 5), ('f', 6), ('g',
1), ('h', 2), ('i', 3), ('j', 4)]
I want to obtain that with a co
I don't recall a modified flag on controls in wxPython.
If you only want to update that which has changed, you probably have
to keep a copy of the result of the query you filled the control with,
and determine the change from comparing it to the current state of the
control.
These guys may have s
"Alan Gauld" <[EMAIL PROTECTED]> wrote
>>>>>first = struct.unpack('', '\x02\x00')
>> error: unpack requires a string argument of length 4
>
> And here you asked for 54 characters but only gave
> it two bytes. And the two byes were 02 and 00 which
> are not printable characters.
Oo
Nirmal Sakthi wrote:
> I am using module struct.unpack() to decode data from a binary file,
> so that I can use the value in a calculation.
>
> I have been able to extract an integer value.
>
> >>>length = struct.unpack('i', '\x9c\x00\x00\x00')
> >>>length = int(length[0])
> >>>
"Nirmal Sakthi" <[EMAIL PROTECTED]> wrote
> I want to be able to extract a string.
>
> I have tried,
>
>>>>first = struct.unpack('s', '\x02\x00')
>>>>first = str(first[0])
>>>>print first
>Traceback (most recent call last):
> ..
>error: unpack requires a string argument of
Shrutarshi Basu wrote:
> I'm working on a module consisting of a number of scripts that handle
> communications over a serial connection. I would like someway for the
> user to be able to specify which serial port to be used based on a
> config file in the same directory as the user's program. Shou
I am using module struct.unpack() to decode data from a binary file, so that
I can use the value in a calculation.
I have been able to extract an integer value.
>>>length = struct.unpack('i', '\x9c\x00\x00\x00')
>>>length = int(length[0])
>>>print length
156
I want to be able
42 matches
Mail list logo