It's an interpreted OO programming language. It has a lot of good libraries for doing many things, a few well liked frameworks for building websites (Django is the biggest, probably), SDL bindings (PyGame), a very popular math/scientific package (numpy), etc. It can be used for pretty much anything, within reason.
Whether it's worth learning or not depends on what you want to do, I suppose. I like it and find it useful for a lot of stuff that I do.
Can somebody tell me what Python is, and what it is used for? I read that the program Blender utilizes it and was wondering if it was worth learning.
Python is an interpreted scripting language that makes general programming tasks easier to write, especially in scenarios where blinding-fast speed is not a concern. It has a clean and relatively easy to understand syntax that makes it approachable for people who may not necessarily be full time programmers, like, say, 3D artists
Underneath Python is C++ and C. You can probably assume that Blender uses Python to serve as a bridge between 3D artists and the very complicated C/C++ that powers Blender.
Over the nearly 5 years I've been at my company I've heard various people propose we should do more C++ development over C. When people point out the various additional and myriad ways to shoot yourself in the foot with C++, they usually respond with, "well, we'll just tell them not to use that stuff!"
Okay, well, we've been telling people not to do the various dumb things you can do in C for 20 years and they still do it, so I don't see how that's going to work. And so Linus finally sums it up the way I've been trying to:
In other words, the only way to do good, efficient, and system-level and portable C++ ends up to limit yourself to all the things that are basically available in C.
Monkey Ball WarriorA collection of mediocre hatsSeattle, WARegistered Userregular
edited November 2011
It always seemed kind of ironic to me that I know C, and I know Java and C# and Go and various other high level languages, but I never bothered to learn C++. From the outside it just seems like a messy hack. Not that Java isn't also messy, because it is.
Most of the schools around here teach people using Java, but if I were to pick one I would say Python or C, depending if you wanted to teach top-to-bottom or bottom-to-top.
Monkey Ball Warrior on
"I resent the entire notion of a body as an ante and then raise you a generalized dissatisfaction with physicality itself" -- Tycho
I had one class on C++ (my Computer Programming III class) and the rest were in Java. Some Python/Ruby/C, but mainly Java. It's now the only language I'm comfortable with at the moment.
Though my very first programming language WAS C++, and that was in High School. I do kinda miss the language.
Mine was pascal. I feel old now.
Edit: Technically it was Cobol if you count me helping my mother out with her night courses when I was young. But the first language someone taught me was pascal.
My first was TI-Basic on a Ti-99/4a. To be fair, I only sort of even remember doing that and since I was like 5 I'm sure it was nothing impressive. I have been told that I messed around with it though. The first that I really understood that "hey, I'm doing programming" was QBasic
QBasic, then to C++, then to C, then to Java, then to VB, then C++.NET, then C#.
I did do shit on my graphing calculator. I remember I actually wrote a timer that was accurate to the second after 4 hours. I never really had the patience to let it go longer than that.
not a doctor, not a lawyer, examples I use may not be fully researched so don't take out of context plz, don't @ me
Honestly the parts of C++ I use most are just syntax sugar over C. I still wish there was a C# compiler, that wasn't a pile of steaming shit.
Everytime a student gives me a C# assignment, I know I'm going to have to deal with Mono, and I die a little inside.
Mono is mostly a pile of trash, but the AOT compiler is like... swimming in raw sewage. The GTK nonsense instead of focusing on making winforms okay annoys me to piss.
not a doctor, not a lawyer, examples I use may not be fully researched so don't take out of context plz, don't @ me
The GTK nonsense instead of focusing on making winforms okay annoys me to piss.
Considering mono had to completely re-implement WinForms, that shouldn't really be a surprise. GTK#'s implementation is probably about as simple as WinForms's implementation is on Windows.
I wish that someway, somehow, that I could save every one of us
Though my very first programming language WAS C++, and that was in High School. I do kinda miss the language.
Mine was pascal. I feel old now.
Edit: Technically it was Cobol if you count me helping my mother out with her night courses when I was young. But the first language someone taught me was pascal.
I taught myself QBasic because it came with DOS. I thought it was hte funniest shit when I figured out how to write a program that would ask you how old you were and then it would tell you you were old.
Now I'm a JAVA whore. I know it has its problems, but I just feel comfy cozy using it.
Well they're supposed to help guide implementation before you get to the point where you're like "oh I need this here instead of here." and need to change your whole class library. At least you save yourself from rewriting the code 3-4 times or start hacking pieces because implementation can't easily match planning.
not a doctor, not a lawyer, examples I use may not be fully researched so don't take out of context plz, don't @ me
If the design is boring you need to work on more interesting problems!
I think my hands-on exposure was Commodore BASIC, GWBASIC, QBASIC/QuickBasic, x86 ASM, Pascal, C/C++, and then after that it really doesn't matter. The language and tools became not so important.
Designing is definitely more interesting than writing out code once you know exactly how everything has to work, but I do prefer to "design" while writing code after getting a fairly high level idea in my head. Drawing ERDs and class diagrams and remembering to put every attribute and method and whatnot in them is boring. Getting a rough idea, writing some code to see how it works, and then fixing or adding more is fun. I think because I get to see actual results and experiment with ideas that I wasn't sure if they'd work or not sooner.
I'm not advocating it as a good way to do large projects at work or something that new developers should be encouraged to do. You do end up wasting time implementing stupid stuff and going back and changing things after you realize you've gotten yourself stuck in a corner and unable to do something you need to. I find it way more interesting for smaller projects and personal projects, though. Sort of a 1 man scrum process... sort of.
Designing is definitely more interesting than writing out code once you know exactly how everything has to work, but I do prefer to "design" while writing code after getting a fairly high level idea in my head. Drawing ERDs and class diagrams and remembering to put every attribute and method and whatnot in them is boring. Getting a rough idea, writing some code to see how it works, and then fixing or adding more is fun. I think because I get to see actual results and experiment with ideas that I wasn't sure if they'd work or not sooner.
So, I recently finished reading coders at work, which is a pretty decent beach book if nothing else. What I took away from it is if you ask 10 great programmers how to best build a program, you will get 15 conflicting answers.
Designing is definitely more interesting than writing out code once you know exactly how everything has to work, but I do prefer to "design" while writing code after getting a fairly high level idea in my head. Drawing ERDs and class diagrams and remembering to put every attribute and method and whatnot in them is boring. Getting a rough idea, writing some code to see how it works, and then fixing or adding more is fun. I think because I get to see actual results and experiment with ideas that I wasn't sure if they'd work or not sooner.
So, I recently finished reading coders at work, which is a pretty decent beach book if nothing else. What I took away from it is if you ask 10 great programmers how to best build a program, you will get 15 conflicting answers.
That's not terribly surprising. "Writing code" covers a whole lot of different skill sets and core areas which some people are going to be better at or find more interesting than others, while all of them are overall competent and intelligent people.
I've come to the conclusion that the best solution to my current thing I'm implementing at work is a unique partial index. That's great, we're using pgsql which supports them. Django does not, though. Rather than having to document somewhere externally that this index needs to be manually created after running syncdb, I'd really like to find some way to just have this happen within my app or model's code, possibly through a signal handler.
The best signal appears to be post_syncdb. The documentation for that signal also says not to alter the database within a post_syncdb signal handler because it'll break stuff. Does adding an index constitute table alteration? Is there a better signal that I haven't come across, even if added by a 3rd party app like django-south or django-evolution?
A partial index is not very portable and there won't be any clean way to do this I imagine. I don't think there is any appopriate place to hook this as part of the django model, since the model simply should not and will not support it, so hacking it in while good-intentioned seems like the wrong thing to do.
Treat it as part of database tuning and document it properly? edit: Basically, having some non-obvious "magic" create some indexes is worse than having a clear script somewhere that can be run after deployment of your app for "performance tuning" modifications.
The lack of portability is something I've been considering, but realistically, we aren't going to be running this on anything but pgsql any time soon and probably not ever and it won't ever be distributed.
I think having it in the code with the rest of the app is fairly clear and obvious. Using signal handlers to do stuff is standard procedure and not anything that should confuse anyone. If doing this from post_syncdb is safe then it can even print what it's doing alongside the rest of the db creation output where it says "Installing indexes" and whatnot so that you know it's happening. I'd be more inclined to agree if this was truly a performance tuning thing, but this is a data integrity thing (although not super critical data integrity). The integrity can be mostly enforced in code, but leaves a slim chance race condition in place that can result in duplicate data that shouldn't be duplicate between checking for uniqueness and inserting a new row.
In the end I'll bring up the possible solutions with the rest of the devs and the dba's here to see what is preferred as a group, but I want to investigate all of the options. At this point even "document the race condition and leave it because it's really super easy to clean up and won't seriously break anything" is on the table.
yeah, I'm going to see what happens on my dev vm to see. One of the other guys here may also have a better solution. He had a similar situation that he was able to solve relying on the atomicity of the transaction, but it was a slightly different situation, so he's not sure it'll work. He's looking for the code so that we can take a look to see.
The pure code solution relying on the transaction did not work for this. The post_syncdb signal seems to work right so far. I set it so that it only creates the index after processing the very last installed app. It creates the index on initial run just fun. On runs after that it raises an exception since the constraint already exists, which is fine.
I may still have the index just added separately, as much as I'd prefer for it to be automated. I am nervous that I just don't fully understand the implications of what I've done here and so something could blow up in 6 months.
I still predict that a working solution can be find but that it would be not worth the maintenance woes or fragility. Good luck.
On an unrelated note, we've been prepping most of this week for our go-live on Tuesday. I'll be doing a 12 hour shift supporting it on-site the first day. Weeeeeeeeeeeee.
Our part of the project is pretty ready thankfully.
Yeah, Monday I'll have to run everything by a few people at work to get everyone else's thoughts. Just about everyone was out of the office today. I'd really like for it to be maintained when the models are created just like all the other unique constraints.
I'm actually tempted to look into how big of a pain in the ass it would be to add a unique_partial to Meta, kind of like unique_together, but takes tuples of lists of the columns to be unique and the limiting attribute values like (('attributes','for','unique'),(a=3,b=True)) that would work on the db's that have partial indexes and gracefully just not do it on the ones that don't. I can't name any off the top of my head, so I could be remembering wrong, but it seems like there are a few other Django features that behave like that. That would not be an immediate solution for work, just something interesting to do for fun.
Though my very first programming language WAS C++, and that was in High School. I do kinda miss the language.
Mine was pascal. I feel old now.
Edit: Technically it was Cobol if you count me helping my mother out with her night courses when I was young. But the first language someone taught me was pascal.
I taught myself QBasic because it came with DOS. I thought it was hte funniest shit when I figured out how to write a program that would ask you how old you were and then it would tell you you were old.
Now I'm a JAVA whore. I know it has its problems, but I just feel comfy cozy using it.
Technically BASIC was my first, though I didn't truly "learn" it as such. I really started with VB.NET (which is what my IT class used), eventually moved on to C#. I do stuff with AS3 and I've dabbled a bit in C, C++ and MIPS, but C# is pretty much my comfort zone these days.
0
Monkey Ball WarriorA collection of mediocre hatsSeattle, WARegistered Userregular
edited November 2011
My usage of C# has been marred by having to use it to drive asp.net, which is just horrible. Or at least it seems horrible, I don't have much other experience with web frameworks.
I really like C#'s syntax, though. The library leaves something to be desired, especially organizationally, but it's not horrible.
But after using C# and Go a lot, I'm not sure I can deal with not having function types anymore. Even C has function pointers... Java just seems goofy in this respect.
Monkey Ball Warrior on
"I resent the entire notion of a body as an ante and then raise you a generalized dissatisfaction with physicality itself" -- Tycho
0
The AnonymousUh, uh, uhhhhhh...Uh, uh.Registered Userregular
That's what reflection is for. :P
0
admanbunionize your workplaceSeattle, WARegistered Userregular
My usage of C# has been marred by having to use it to drive asp.net, which is just horrible. Or at least it seems horrible, I don't have much other experience with web frameworks.
I really like C#'s syntax, though. The library leaves something to be desired, especially organizationally, but it's not horrible.
But after using C# and Go a lot, I'm not sure I can deal with not having function types anymore. Even C has function pointers... Java just seems goofy in this respect.
ASP.NET basically exists to allow Microsoft web forms developers to continue doing exactly what they've always done without having to learn any new concepts that were developed in the last, ohhh, 5 years.
My usage of C# has been marred by having to use it to drive asp.net, which is just horrible. Or at least it seems horrible, I don't have much other experience with web frameworks.
I really like C#'s syntax, though. The library leaves something to be desired, especially organizationally, but it's not horrible.
But after using C# and Go a lot, I'm not sure I can deal with not having function types anymore. Even C has function pointers... Java just seems goofy in this respect.
ASP.NET basically exists to allow Microsoft web forms developers to continue doing exactly what they've always done without having to learn any new concepts that were developed in the last, ohhh, 5 years.
Which makes sense because it was released 9 years ago.
Posts
Whether it's worth learning or not depends on what you want to do, I suppose. I like it and find it useful for a lot of stuff that I do.
Python is an interpreted scripting language that makes general programming tasks easier to write, especially in scenarios where blinding-fast speed is not a concern. It has a clean and relatively easy to understand syntax that makes it approachable for people who may not necessarily be full time programmers, like, say, 3D artists
Underneath Python is C++ and C. You can probably assume that Blender uses Python to serve as a bridge between 3D artists and the very complicated C/C++ that powers Blender.
Over the nearly 5 years I've been at my company I've heard various people propose we should do more C++ development over C. When people point out the various additional and myriad ways to shoot yourself in the foot with C++, they usually respond with, "well, we'll just tell them not to use that stuff!"
Okay, well, we've been telling people not to do the various dumb things you can do in C for 20 years and they still do it, so I don't see how that's going to work. And so Linus finally sums it up the way I've been trying to:
SE++ Forum Battle Archive
Most of the schools around here teach people using Java, but if I were to pick one I would say Python or C, depending if you wanted to teach top-to-bottom or bottom-to-top.
SE++ Forum Battle Archive
Mine was pascal. I feel old now.
Edit: Technically it was Cobol if you count me helping my mother out with her night courses when I was young. But the first language someone taught me was pascal.
Everytime a student gives me a C# assignment, I know I'm going to have to deal with Mono, and I die a little inside.
I did do shit on my graphing calculator. I remember I actually wrote a timer that was accurate to the second after 4 hours. I never really had the patience to let it go longer than that.
Mono is mostly a pile of trash, but the AOT compiler is like... swimming in raw sewage. The GTK nonsense instead of focusing on making winforms okay annoys me to piss.
Considering mono had to completely re-implement WinForms, that shouldn't really be a surprise. GTK#'s implementation is probably about as simple as WinForms's implementation is on Windows.
Every time.
I taught myself QBasic because it came with DOS. I thought it was hte funniest shit when I figured out how to write a program that would ask you how old you were and then it would tell you you were old.
Now I'm a JAVA whore. I know it has its problems, but I just feel comfy cozy using it.
I think my hands-on exposure was Commodore BASIC, GWBASIC, QBASIC/QuickBasic, x86 ASM, Pascal, C/C++, and then after that it really doesn't matter. The language and tools became not so important.
I'm not advocating it as a good way to do large projects at work or something that new developers should be encouraged to do. You do end up wasting time implementing stupid stuff and going back and changing things after you realize you've gotten yourself stuck in a corner and unable to do something you need to. I find it way more interesting for smaller projects and personal projects, though. Sort of a 1 man scrum process... sort of.
So, I recently finished reading coders at work, which is a pretty decent beach book if nothing else. What I took away from it is if you ask 10 great programmers how to best build a program, you will get 15 conflicting answers.
The best signal appears to be post_syncdb. The documentation for that signal also says not to alter the database within a post_syncdb signal handler because it'll break stuff. Does adding an index constitute table alteration? Is there a better signal that I haven't come across, even if added by a 3rd party app like django-south or django-evolution?
Treat it as part of database tuning and document it properly? edit: Basically, having some non-obvious "magic" create some indexes is worse than having a clear script somewhere that can be run after deployment of your app for "performance tuning" modifications.
I think having it in the code with the rest of the app is fairly clear and obvious. Using signal handlers to do stuff is standard procedure and not anything that should confuse anyone. If doing this from post_syncdb is safe then it can even print what it's doing alongside the rest of the db creation output where it says "Installing indexes" and whatnot so that you know it's happening. I'd be more inclined to agree if this was truly a performance tuning thing, but this is a data integrity thing (although not super critical data integrity). The integrity can be mostly enforced in code, but leaves a slim chance race condition in place that can result in duplicate data that shouldn't be duplicate between checking for uniqueness and inserting a new row.
In the end I'll bring up the possible solutions with the rest of the devs and the dba's here to see what is preferred as a group, but I want to investigate all of the options. At this point even "document the race condition and leave it because it's really super easy to clean up and won't seriously break anything" is on the table.
Will the way you execute the index cause a syncdb/flush? Test it I guess.
I may still have the index just added separately, as much as I'd prefer for it to be automated. I am nervous that I just don't fully understand the implications of what I've done here and so something could blow up in 6 months.
On an unrelated note, we've been prepping most of this week for our go-live on Tuesday. I'll be doing a 12 hour shift supporting it on-site the first day. Weeeeeeeeeeeee.
Our part of the project is pretty ready thankfully.
I'm actually tempted to look into how big of a pain in the ass it would be to add a unique_partial to Meta, kind of like unique_together, but takes tuples of lists of the columns to be unique and the limiting attribute values like (('attributes','for','unique'),(a=3,b=True)) that would work on the db's that have partial indexes and gracefully just not do it on the ones that don't. I can't name any off the top of my head, so I could be remembering wrong, but it seems like there are a few other Django features that behave like that. That would not be an immediate solution for work, just something interesting to do for fun.
I'd probably have it fail if the database isn't Postgres/MS, since it is a unique index and has a functional difference as you mentioned.
Wonder if someone has already made that customization. There's one already for composite primary key support.
I really like C#'s syntax, though. The library leaves something to be desired, especially organizationally, but it's not horrible.
But after using C# and Go a lot, I'm not sure I can deal with not having function types anymore. Even C has function pointers... Java just seems goofy in this respect.
ASP.NET basically exists to allow Microsoft web forms developers to continue doing exactly what they've always done without having to learn any new concepts that were developed in the last, ohhh, 5 years.
Which makes sense because it was released 9 years ago.