LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 06-22-2010, 01:25 PM   #1
narnie
Member
 
Registered: Jan 2010
Distribution: Linux Mint, Ubuntu Netbook Edition, et al
Posts: 108

Rep: Reputation: 17
In Python, what does "x = 5" really do/mean?


Hi,

I'm a great scripter, but just learning programming (using Python).

I'm very much a newbie at this, so please be patient as I'm sure these will seem so basic a questions and may seem stupid to those experienced.

I'm reading a python book right now that has me thinking about variables.

As the title says, what does "x=5" really mean?

What is the "5" being assigned to? Is "x" considered an "instance" of "int?"

If I do this:
Code:
>>> class test(int):
    pass

>>> x=test(5)
>>> x
5
>>>
Then x here is an instance of class test(), a subclass of int.

But with int, you can do x=5.

If I do that after the above code, then x is no longer an instance of test() but is a variable of type int().

In the above, what is the 5 actually being assigned to in the instance of test()?

I have accessed it by defining a class and doing this just messing around:

Code:
>>> class test2(int):
    def value(self):
        print self
        self += 1
        print self

        
>>> x=test2(5)
>>> x
5
>>> x.value()
5
6
>>> x
5
Why doesn't the value of x change to 6 in the above example? I'm I "redefining" self in the value() method to no longer reflect what is self in the instance?

Also, can I "hijack" what x=5 means to to add my own methods, but it still behave like x=5. What I mean might be explained by this code:

Code:
#do whatever code here to "hijack" int()

>>> x=5
>>> x
5
>>> x.make_negative
>>> x
-5
>>> x=-2
>>> x
-2
>>> x.make_negative
>>> x
2
Or something like that?

If there is no way to do that and we go back to my original subclass definition, how do I change the value of the instance of the class to another value?

In:
Code:
>>> x=5
>>> x += 1
>>> x
6
How does the value of x become incremented internally? What magic is happening behind the scenes?

Say I want to do what is verboten in Python. Make in C-like incrementor like this.

Code:
>>> class Incrementor(int):
    def incAfter (self): # equivalent of x++
        #do whatever to access the value of instance
        return VALUE_OF_INSTANCE # as in x=Incrementor(5)
        VALUE_OF_INSTANCE += 1 # not quite sure how to do this to make it increment after returning the value (perhaps it is imporssible). Help here would be appreciated, too.
    def incBefore(self): # equivalent of ++x
        VALUE_OF_INSTANCE += 1
        return VALUE_OF_INSTANCE # as in x=Incrementor(5)
So that I could do something like this:

Code:
>>> x = Incrementor(5)
>>> x
5
>>> print x.incAfter()
5
>>> x
6
>>> print x.incBefore()
7
>>> x
7
Helping me with the concepts would really go a long way for me. Any help would be greatly appreciated.

Thankfully,
Narnie
 
Old 06-22-2010, 03:03 PM   #2
paulsm4
LQ Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
Hi -

In a word, you're asking about "binding".

As it happens, Python is VERY different from C, Java or C#, and in fact very MUCH like shell, LISP or Smalltalk.

This link might clarify:
http://lackingrhoticity.blogspot.com...tics-part.html

'Hope that helps .. PSM
 
Old 06-22-2010, 11:25 PM   #3
narnie
Member
 
Registered: Jan 2010
Distribution: Linux Mint, Ubuntu Netbook Edition, et al
Posts: 108

Original Poster
Rep: Reputation: 17
Quote:
Originally Posted by paulsm4 View Post
Hi -

In a word, you're asking about "binding".

As it happens, Python is VERY different from C, Java or C#, and in fact very MUCH like shell, LISP or Smalltalk.

This link might clarify:
http://lackingrhoticity.blogspot.com...tics-part.html

'Hope that helps .. PSM
Thanks! I'll give it a look.



Narnie
 
Old 06-22-2010, 11:47 PM   #4
robotsari
LQ Newbie
 
Registered: Jun 2010
Location: boston & sf bay, depending on the day
Distribution: ubuntu, rhel, debian
Posts: 20

Rep: Reputation: 1
Quote:
Originally Posted by narnie View Post
Hi,

I'm a great scripter, but just learning programming (using Python).

I'm very much a newbie at this, so please be patient as I'm sure these will seem so basic a questions and may seem stupid to those experienced.

I'm reading a python book right now that has me thinking about variables.

As the title says, what does "x=5" really mean?

What is the "5" being assigned to? Is "x" considered an "instance" of "int?"
The first thing you are missing is that Python is NOT a statically typed language. In Python you can easily do something like

Code:
x = 5
print type(x)
x = "hello"
print type(x)
x is just a variable; it can hold anything you'd like. You also can code straight functions; you don't need to base your code on classes. I teach an introductory Python course every January, and I teach it from a functional standpoint and then gradually introduce classes. I'm curious what resources you're using to learn. The course resources here:

http://ocw.mit.edu/courses/electrica...2010/index.htm

provides good readings under the Readings section.

Particularly, under the Readings section, Ch 2 & 3 of the 6.01 course notes provide good descriptions of binding environments and how the Python interpreter deals with variables. My advice is to get comfortable with functional programming first before delving into classes.

Good luck and continue to ask questions throughout
 
Old 06-23-2010, 12:06 AM   #5
paulsm4
LQ Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
Hi, Narnie -

The point I was trying to make (the full and complete answer to your original question) is, as robotsari said, "Python is not a statically bound language". This can come as quite a "culture shock" to folks who are accustomed to statically typed languages. Which have been, frankly, the majority of programming languages for the last 20 years or so (FORTRAN, C, Pascal, Ada, Objective-C, C++, Java, etc etc are all - for the most part - statically typed).

The key to understanding the answer to your question is to understand the concept of "variable binding". I think the link I gave you does a good job; you'll find many, many other links on the web that might do a better job.

HOWEVER ....

I want to emphasize that "static binding" does NOT necessarily have anything to do with "functional programming". They're separate concepts.

I also want to emphasize that Python is not a "functional language". Python SUPPORTS "functional programming". Just as Python ALSO supports "object oriented programming", and "structured programming".

Here's a great link on the "functional programming" aspect of Python (and it IS just an "aspect" - NOT the whole enchilada):

http://www.ibm.com/developerworks/library/l-prog.html

Here's another great link about "Is Python really a functional language?":

http://groups.google.com/group/comp....cafa56e65429ef

Also, for the last 20 years or so, we've all been hearing about how great "object oriented programming" is. It isn't. It's just a tool, one that can be used effectively, or used poorly. And frankly, I think C++ has been a DISASTER for an entire generation of software development. I honestly think the software world would have been a better place if we'd just stagnated with C or FORTRAN, or popularized a DIFFERENT OO language like Objective-C, or Object-Pascal, or Smalltalk ... or just about ANYTHING besides C++.

In any case, I think we're seeing a rising interest in functional programming that might quickly swell into a tsunami that might even sweep away C++, C# and Java in its wake. And I think that would be a Healthy Thing Here's a a very, VERY good article that explains my feelings MUCH better than I'm doing:

http://www.artima.com/weblogs/viewpo...?thread=274019

These are definitely exciting times in software development.

Enjoy!

Last edited by paulsm4; 06-23-2010 at 12:19 AM.
 
Old 06-23-2010, 02:09 AM   #6
robotsari
LQ Newbie
 
Registered: Jun 2010
Location: boston & sf bay, depending on the day
Distribution: ubuntu, rhel, debian
Posts: 20

Rep: Reputation: 1
Heh, yeah I should have made my post clearer. thanks paulsm4; you are correct. My point about non-statically typed variables should have been made separate from my point about functional programming.

I should have quoted more of narnie's original post; I was merely trying to say that, if you're learning Python and still struggling with the concept of non-statically typed variables, it is probably best to start with just getting the syntax down by writing some functions.

Once the syntax is clear, tackling classes becomes a bit easier. Since Python has some weird things going on with syntax, typing and binding environments, trying to learn it simultaneously with learning object-oriented stuff can be overwhelming. In my experience teaching totally-new programmers and new-to-Python programmers, my students learned much more slowly and were more frustrated when I started the course by introducing object-oriented concepts.

But when you get to classes, learn about the Python __init__ method to set instance variables. A cursory glance at your incrementor, I think I would code like this:

Code:
class Incrementor(): # inheritance isn't necessary to make a class 
    def __init__(self, value = 0): # default parameter
        self.value = value         # set instance variable value
    
    def incAfter(self): # equivalent of x++
        self.value += 1
        return self.value - 1 # you cannot put code after a return
    
    def incBefore(self): # equivalent of ++x
        self.value += 1
        return self.value


>> x = Incrementor()
>> print x
<Incrementor instance at 0x12fcd40>

>> print x.value
0

>> x.incAfter()
0

>> print x.value
1

>> x.incBefore()
2

>> print x.value
2

Last edited by robotsari; 06-23-2010 at 02:16 AM. Reason: haha not done yet
 
Old 06-23-2010, 02:33 AM   #7
bigearsbilly
Senior Member
 
Registered: Mar 2004
Location: england
Distribution: Mint, Armbian, NetBSD, Puppy, Raspbian
Posts: 3,515

Rep: Reputation: 239Reputation: 239Reputation: 239
I don't know python that well, (I like C++ paul )
but are you asking why a class derived from an int
doesn't seem to behave as you think?

I should imagine, that the fundamental types, ints chars floats
are special cases that aren't a real class like other aggregate types.

this would be for efficiency.
but i could, of course, be wrong.
 
Old 06-24-2010, 02:03 AM   #8
narnie
Member
 
Registered: Jan 2010
Distribution: Linux Mint, Ubuntu Netbook Edition, et al
Posts: 108

Original Poster
Rep: Reputation: 17
I can't wait to read all of the above links that you have all given me.

Here is what I have coded (please forgive the obvious docstrings, but I'm just teaching myself how to use them as well. The code does just what I was hoping in principle, but not exactly the way I wanted):

Code:
class Incrementor(object):
    '''
    this module attempts to mimic C-like x++ and ++x functions in Python
    '''
    def __init__(self, value=0):
        '''
        sets the value (default 0) when initialized

        example:

            >>> x = Incrementor (5)
        '''
        self.__value = value

    def __call__(self):
        '''
        allows the variable to be called

        example
            >>> x()
            5
        '''
        return self.__value

    def __repr__(self):
        '''
        allows the varible to be display without ()

        example:
            >>> x
            5
        '''
        return str(self.__value)

    def setValue(self, value):
        '''
        sets/changes the value of the object
        '''
        self.__value = value

    def incAfter(self, increment=1):
        '''
        increments the value of the object after returning the object value

        example:
            >>> print x
            5
            >>> print x.incAfter()
            5
            >>> print x
            6
        '''
        oldvalue = self.__value
        self.__value += increment
        return oldvalue

    def iA(self,increment=1):
        '''
        shorthand for incAfter method
        '''
        return self.incAfter(increment)

    def incBefore(self, increment=1):
        '''
        increments the value of the object before returning the object value

        example:
            >>> print x
            5
            >>> print x.incBefore()
            6
            >>> print x
            6
        '''
        self.__value += increment
        return self.__value

    def iB(self, increment=1):
        '''
        shorthand for incBefore method
        '''
        return self.incBefore(increment)

    def decAfter(self,increment=1):
        '''
        decrements the value of the object after returning the object value

        example:
            >>> print x
            5
            >>> print x.decAfter()
            5
            >>> print x
            4
        '''
        oldvalue = self.__value
        self.__value -= increment
        return oldvalue

    def dA(self, increment=1):
        '''
        shorthand for decAfter method
        '''
        return self.decAfter(increment)

    def decBefore(self, increment=1):
        '''
        decrements the value of the object before returning the object value

        example:
            >>> print x
            5
            >>> print x.decBefore()
            4
            >>> print x
            4
        '''
        self.__value -= increment
        return self.__value

    def dB(self, increment=1):
        '''
        shorthand for decBefore method
        '''
        return self.decBefore(increment)

    def multAfter(self, multiple=1):
        '''
        multiple of the value of the object before returning the object value

        example:
            >>> print x
            5
            >>> print x.multAfter(2)
            5
            >>> print x
            10
        '''
        oldvalue = self.__value
        self.__value *= multiple
        return oldvalue

    def multBefore(self, multiple=1):
        '''
        multiple of the value of the object after returning the object value

        example:
            >>> print x
            5
            >>> print x.multAfter(2)
            5
            >>> print x
            10
        '''
        self.__value *= multiple
        return self.__value

    def divAfter(self, divisor=1):
        '''
        value of the object divided by divisor after returning the object value

        example:
            >>> print x
            5
            >>> print x.divAfter(2.0)
            5
            >>> print x
            2.5
        '''
        oldvalue = self.__value
        self.__value /= divisor
        return oldvalue

    def divBefore(self, divisor=1):
        '''
        value of the object divided by divisor before returning the object value

        example:
            >>> print x
            5
            >>> print x.divBefore(2.0)
            2.5
            >>> print x
            2.5
        '''
        self.__value /=  divisor
        return self.__value
Playing around shows:

Code:
>>> x = Incrementor(5)
>>> x
5
>>> x.incAfter()
5
>>> x
6
>>> x.decBefore()
5
>>> x.setValue(7)
>>> x
7
>>> print x.incBefore(2)
9
>>> print x.incAfter(2)
9
>>> x
11
>>> print x.decBefore(2)
9
>>> x
9
>>> print x.multBefore(2)
18
>>> print x.divAfter(4.0)
18
>>> x
4.5
>>> x()
4.5
>>>
I was hoping to redefine what x = 5 means. I was hoping to make x = 5 bind to my type rather than what it normally does. I have since found out that it probably can't be done as it is deep within the language.

Regardless, this has been an excellent learning tool for me to play around with even though using incrementors like this isn't very Pythonish (read a few days ago that using enumerate() and itertools obviate the need for incrementors)

It has taught me much about classes (so much left to learn).

I really am liking learning Python.

Thanks for all the help and any further tips are appreciated.

Cheerio,
Narnie
 
Old 06-24-2010, 02:24 AM   #9
narnie
Member
 
Registered: Jan 2010
Distribution: Linux Mint, Ubuntu Netbook Edition, et al
Posts: 108

Original Poster
Rep: Reputation: 17
Quote:
Originally Posted by robotsari View Post
The first thing you are missing is that Python is NOT a statically typed language. In Python you can easily do something like

Code:
x = 5
print type(x)
x = "hello"
print type(x)
x is just a variable; it can hold anything you'd like. You also can code straight functions; you don't need to base your code on classes. I teach an introductory Python course every January, and I teach it from a functional standpoint and then gradually introduce classes. I'm curious what resources you're using to learn. The course resources here:

http://ocw.mit.edu/courses/electrica...2010/index.htm

provides good readings under the Readings section.

Particularly, under the Readings section, Ch 2 & 3 of the 6.01 course notes provide good descriptions of binding environments and how the Python interpreter deals with variables. My advice is to get comfortable with functional programming first before delving into classes.

Good luck and continue to ask questions throughout
I have realized that about x (variables in general). I have played around with functions, but wanted to learn more (probably too quickly). I write a lot of abstraction using functions in my scripting (which is all self-taught {loved the SAM'S teach yourself scripting from late 1990s that a just read this past year and then "graduated" to advanced bash techniques where I used $((x++))-type code all the time which calls on the underlying C code [or is it C+ or C++?] from what I understand}).

What I was really hoping to do was change the behavior of x = 5 from binding x to the int type to x = 5 binding to MY type (not as in x = Incrementor() because as soon as you do x = 5 then you loose your binding to the Incrementor class). I want x = 5 to bind to what I want it to so I can use my methods on x and resetting it without resorting to calling a method (like x.setValue = 5), but I have since learned that x = 5 is likely buried too deeply into the core of the language to make that statement bind to my "type."

The initial resources I've used are from Apress:
Python for Absolute Beginners by Tim Hall and J-P Stacey (which I found didn't fit my learning style very well and didn't explain the details I like and thus I found myself frustrated).
Python from Novice to Professional by Magnus Lie Hetland (which I'm finding brilliant for me!)

I can't wait to read your link. I'd love to take your course, then I could ask questions as I have them (but not to interrupt class too much).

I am going to have to read some of this things about "functional" programming, as I'm not entirely clear on what that means.

It seems to me, Python can be used pretty much however meets one's style, but I could be way off on that.

I can't wait to get into GUI (preferrably PyGTK to make it look nice in Gnome. This book is teaching wxpython to some degree, but that doesn't end up looking as nice but perhaps I will get concepts down and go from there). Know any good resources for PyGTK for later (I have a feeling it will be a while before I can really get that as I'm just now building my base for the language)?

I appreciate your encouragement and your asking me to ask questions. I love to help others with their scripting needs, and I can't wait until I can do similarly with Python in the (hopefully) not too distant future.

Thanks for all the help,
Narnie

Last edited by narnie; 06-24-2010 at 02:44 AM.
 
Old 06-24-2010, 02:37 AM   #10
narnie
Member
 
Registered: Jan 2010
Distribution: Linux Mint, Ubuntu Netbook Edition, et al
Posts: 108

Original Poster
Rep: Reputation: 17
Quote:
Originally Posted by paulsm4 View Post
Hi, Narnie -

The point I was trying to make (the full and complete answer to your original question) is, as robotsari said, "Python is not a statically bound language". This can come as quite a "culture shock" to folks who are accustomed to statically typed languages. Which have been, frankly, the majority of programming languages for the last 20 years or so (FORTRAN, C, Pascal, Ada, Objective-C, C++, Java, etc etc are all - for the most part - statically typed).

The key to understanding the answer to your question is to understand the concept of "variable binding". I think the link I gave you does a good job; you'll find many, many other links on the web that might do a better job.

HOWEVER ....

I want to emphasize that "static binding" does NOT necessarily have anything to do with "functional programming". They're separate concepts.

I also want to emphasize that Python is not a "functional language". Python SUPPORTS "functional programming". Just as Python ALSO supports "object oriented programming", and "structured programming".

Here's a great link on the "functional programming" aspect of Python (and it IS just an "aspect" - NOT the whole enchilada):

http://www.ibm.com/developerworks/library/l-prog.html

Here's another great link about "Is Python really a functional language?":

http://groups.google.com/group/comp....cafa56e65429ef

Also, for the last 20 years or so, we've all been hearing about how great "object oriented programming" is. It isn't. It's just a tool, one that can be used effectively, or used poorly. And frankly, I think C++ has been a DISASTER for an entire generation of software development. I honestly think the software world would have been a better place if we'd just stagnated with C or FORTRAN, or popularized a DIFFERENT OO language like Objective-C, or Object-Pascal, or Smalltalk ... or just about ANYTHING besides C++.

In any case, I think we're seeing a rising interest in functional programming that might quickly swell into a tsunami that might even sweep away C++, C# and Java in its wake. And I think that would be a Healthy Thing Here's a a very, VERY good article that explains my feelings MUCH better than I'm doing:

http://www.artima.com/weblogs/viewpo...?thread=274019

These are definitely exciting times in software development.

Enjoy!
I think I remember reading in the first book about it, but I'm not sure. Is "statically typed" meaning that a variable has to be declared and its type given before use? Something like:

declare x integer
declare y float
declare z string

???

If so, NOT having to do this in Python is one of the things I really find appealing, because in my more comfortable scripting environment, I don't have to type variables either. I know NOT having to can lead to some gotchas, but I really think it is brilliant how Python (intelligently) determines the type on the fly by the context of the value (way to go, Guido!). HAVING to do so to me just seems so "formal."

I'm excited to read the above to better understand what "functional" programming means.

I am so new to programming (aside from shell scripting) that all these concepts are still a bit vague to me. I have read about OOP and the examples in the first book show how it can be useful, but at times, OOPing a task seems overkill and unnatural. Sometimes things are so simple, no abstractions are necessary (in my newbie-for-what-its-worth opinion).

Right now, I'm open to all ideas, though. I would like to better understand the landscape I am entering and understand diverse viewpoints and arguments. I am interesting in learning more about your viewpoint about what C++ has done wrongly and how it has wasted many years (I know nothing about C++).

I started off learning C on an Amiga computer(well, after learning basic on a Commodore 64 when I was around 12, hehe) but then premed and medical school took away any "free" time I had. 22 years later, I have come back to my "mistress" and am eager to become intimate with her.

Found linux 12 yrs ago as a beta tester for cable modems when I needed to build a router (Caldera Linux anyone?). Went back into some training, so didn't have enough time for learning so back to Windows. Now back to Linux 98% of the time.

Just love this stuff!!!

Yours,
Narnie
 
Old 06-25-2010, 08:04 PM   #11
robotsari
LQ Newbie
 
Registered: Jun 2010
Location: boston & sf bay, depending on the day
Distribution: ubuntu, rhel, debian
Posts: 20

Rep: Reputation: 1
Hi Narnie! By post #8 it looks like you're making great progress. I confess I now understand I think what you were originally asking, and I did not understand. But your thoughts in posts 8 & 9 are correct; I'm glad that you're learning so much and putting the pieces together nicely.

Quote:
Originally Posted by narnie View Post
I think I remember reading in the first book about it, but I'm not sure. Is "statically typed" meaning that a variable has to be declared and its type given before use? Something like:

declare x integer
declare y float
declare z string

???
Yep! In C and other "declarative languages" you must do that.

Quote:
Originally Posted by narnie View Post
If so, NOT having to do this in Python is one of the things I really find appealing, because in my more comfortable scripting environment, I don't have to type variables either. I know NOT having to can lead to some gotchas, but I really think it is brilliant how Python (intelligently) determines the type on the fly by the context of the value (way to go, Guido!). HAVING to do so to me just seems so "formal."
It is formal and seems bulky when the first languages you learn are along the lines of Python & shell scripting. However after learning Java & C I came to understand why those constructs are nice. It makes your life as a programmer of complex libraries easier, for instance: if I define a function and I specify that it takes two ints, if another person tries to use my function with non-int values, a compile-time error will immediately occur. As the programmer I did not have to catch error cases that would occur if the user had passed in objects of non-int type. Basically, there are plusses and minuses to both approaches; I used to evangelize the typeless approach but at this point I cannot definitely say that one is better than the other! In time I think you may feel the same way. It definitely depends on the job you're doing.

Quote:
Originally Posted by narnie View Post
I'm excited to read the above to better understand what "functional" programming means.
Hey you should check out this poll: http://www.linuxquestions.org/questi...-learn-813373/

There's some good discussions on there; I recently made a post talking about Scheme. Scheme is like, the definitive functional language - it's fun to learn (and also typeless (: )

Enjoy! And yes, never stop asking questions!!!
-Sarina
 
Old 06-26-2010, 07:41 AM   #12
narnie
Member
 
Registered: Jan 2010
Distribution: Linux Mint, Ubuntu Netbook Edition, et al
Posts: 108

Original Poster
Rep: Reputation: 17
Quote:
Originally Posted by robotsari View Post
Hi Narnie! By post #8 it looks like you're making great progress. I confess I now understand I think what you were originally asking, and I did not understand. But your thoughts in posts 8 & 9 are correct; I'm glad that you're learning so much and putting the pieces together nicely.



Yep! In C and other "declarative languages" you must do that.



It is formal and seems bulky when the first languages you learn are along the lines of Python & shell scripting. However after learning Java & C I came to understand why those constructs are nice. It makes your life as a programmer of complex libraries easier, for instance: if I define a function and I specify that it takes two ints, if another person tries to use my function with non-int values, a compile-time error will immediately occur. As the programmer I did not have to catch error cases that would occur if the user had passed in objects of non-int type. Basically, there are plusses and minuses to both approaches; I used to evangelize the typeless approach but at this point I cannot definitely say that one is better than the other! In time I think you may feel the same way. It definitely depends on the job you're doing.



Hey you should check out this poll: http://www.linuxquestions.org/questi...-learn-813373/

There's some good discussions on there; I recently made a post talking about Scheme. Scheme is like, the definitive functional language - it's fun to learn (and also typeless (: )

Enjoy! And yes, never stop asking questions!!!
-Sarina
Sarina,
Once again, you are encouraging. Thank you. I bet you're a great teacher. Is it asking for to much info to ask where you teach? Is your course online by any chance? I was think that if it were, I might be able to take it.

I started learning C 20 year ago, but didn't get very far because of premed and med school. I was attracted to python because you don't have to compile it. That kinda makes me scared seeing everything that must be done to set up compiling a program when I compile other people's programs with ./configure, make, make install. It seems rather intimidating. The thought of having to write makefiles on top of coding just seems overwhelming (but perhaps that is automated).

Thanks again for the help,thoughts, and encouragement.

Yours,
Narnie
 
Old 06-28-2010, 11:56 AM   #13
robotsari
LQ Newbie
 
Registered: Jun 2010
Location: boston & sf bay, depending on the day
Distribution: ubuntu, rhel, debian
Posts: 20

Rep: Reputation: 1
Hi Narnie,

Actually, the course I posted at OCW (http://ocw.mit.edu/courses/electrica...2010/index.htm) is mine. The course is a two-week, lab-based intense crash course, but I've also lengthened it to a month for high-school students, which is still intense but a bit more manageable. Solutions aren't posted because it's still an active class and students excel at cheating during term when solutions are on OCW.

I'm still an undergrad, so I instruct and course develop in my spare time; I know it's not the most put-together set of curriculum, but I'm also retooling it over the course of this summer to address some issues - I'm actually quite poor at explaining object oriented programming, for example, as I never actually use it. But feel free to use the resources there, and at the OCW page for 6.00, a full-term intro-to-Python class (http://ocw.mit.edu/courses/electrica...ing-fall-2008/)

And for the record, writing simple C scripts is easy, and testing them is as well. For example if you save the following code:
Code:
#include <stdio.h>
void main() {
   printf("Hello, world!\n");
}
in a file called test.c, you can simply execute the following two commands to first compile the code, then execute it, in a terminal on any *nix system:
Code:
$ gcc test.c
$ ./a.out
So, C isn't too tricky to get started with

Good luck!
 
Old 06-29-2010, 12:35 PM   #14
narnie
Member
 
Registered: Jan 2010
Distribution: Linux Mint, Ubuntu Netbook Edition, et al
Posts: 108

Original Poster
Rep: Reputation: 17
Quote:
Originally Posted by robotsari View Post
Hi Narnie,

I'm still an undergrad, so I instruct and course develop in my spare time; I know it's not the most put-together set of curriculum, but I'm also retooling it over the course of this summer to address some issues - I'm actually quite poor at explaining object oriented programming, for example, as I never actually use it. But feel free to use the resources there, and at the OCW page for 6.00, a full-term intro-to-Python class (http://ocw.mit.edu/courses/electrica...ing-fall-2008/)

So, C isn't too tricky to get started with

Good luck!
I'll bet you're selling yourself short. I am in the airport on my way home from a 5 day conference. I hope to sit down and be able to learn from your course. I'm sure it will be helpful.

Hope you have a good summer and that you get accomplished what you want/need.

Yours,
Narnie
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
net working eth0 eth1 wlan0 "no connection" "no LAN" "no wi-fi" Cayitano Linux - Newbie 5 12-09-2007 07:11 PM
Standard commands give "-bash: open: command not found" even in "su -" and "su root" mibo12 Linux - General 4 11-11-2007 10:18 PM
LXer: Displaying "MyComputer", "Trash", "Network Servers" Icons On A GNOME Desktop LXer Syndicated Linux News 0 04-02-2007 08:31 AM
[python] print "\033[5;",x,"H=>" datbenik Programming 1 01-05-2006 05:12 AM
User "list" running process "python" TroelsSmit Linux - Newbie 2 02-22-2005 04:55 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 01:46 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration