Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Locked thread
spankweasel
Jan 4, 2006

Profane Obituary! posted:

m0nk3yz is organizing Pycon '12?

http://jessenoller.com/about/

Adbot
ADBOT LOVES YOU

Profane Obituary!
May 19, 2009

This Motherfucker is Dead

spankweasel posted:

http://jessenoller.com/about/

Oh I didn't know m0nk3yz was Jesse Noller. How bout that.

LuckySevens
Feb 16, 2004

fear not failure, fear only the limitations of our dreams

FredMSloniker posted:

I think not posting since September 29, 2010 constitutes a bit more than 'not posting a lot'. Even if nothing in the OP needs to be changed (and there is at least one change that even my newbie eyes can see: Python's now on versions 2.7 and 3.2), it'd be good to have it in the hands of someone who can make any necessary changes.

That said, if nobody wants to volunteer to do it, welp.

Programming languages and resources don't change radically, by design. They don't want to break methods/compatibility concerns without fair warning. They try to remain as constant as they can, with meaningful changes taking many years to come through.

If you're looking for the most 'up to date' resources, they're all their in the OP; there's nothing that needs changing. The best things for a newbie are all there, download python and start working through it. Even if you looked at a python thread OP from 4-5 years ago, it would still be useful.

If you wanted more guides or something, well, us programmers have a phrase: DRY. Don't Repeat Yourself. All the best stuff is in the OP and that's not going to change.

German Joey
Dec 18, 2004

Profane Obituary! posted:

Oh I didn't know m0nk3yz was Jesse Noller. How bout that.

how could you look at that face and not see a True Goon, honestly..

tef
May 30, 2004

-> some l-system crap ->

Profane Obituary! posted:

m0nk3yz is organizing Pycon '12?

he is on the board of the psf, a core contributor, and working on pycon :toot:

(also he is a a cool person :3:)


if anyone thinks they can write a better OP, just post in here and we'll ask him/or an admin nicely
to paste it in

in reality: the op is still resonably informative - a lot of the recent python developments don't really affect the beginner python programmer. that, and no-one reads the op before asking questions anyway :v:

tef
May 30, 2004

-> some l-system crap ->
Moving away from the meta discussion

FredMSloniker posted:

I just decided to take a look at this thread because I'm pondering learning a programming language besides BASIC and writing a game with it.

Just start coding. Python will be a little different to basic (i.e how objects work and are passed around), but most of it will feel pretty familiar.

I would start with the official python tutorial before playing around with a library like pygame or pyglet

I wish I could recommend 3.0, but if you want to write games, python 2.7 will be better in terms of compatibility, and 3.0 isn't much of a change for most programs.

LuckySevens
Feb 16, 2004

fear not failure, fear only the limitations of our dreams

I stumbled onto m0nk3yz homepage, and lost 3 hours of my life reading his python good to great collection.

Exactly the types of topics I was looking to take my python knowledge to the next level.

tef
May 30, 2004

-> some l-system crap ->
I'd also add the following to the list, albeit more about CPython than Python, but useful nonetheless:

http://bugs.python.org/file4451/timsort.txt -- aka why python has the best* sorting algorithm

http://svn.python.org/view/*checkout*/python/trunk/Objects/dictnotes.txt -- how pythons dicts are implemented

despite not being as shiny or as advanced as implementations like PyPy, CPython has had a lot of good ideas under the covers, and it is worth reading abou them

I'd also recommend any talks by raymond hettinger

* for stable sorting of objects - things like dual pivot quick sort or radix sort can outperform it for different constraints

Innocent Bystander
May 8, 2007
Born in the LOLbarn.
Grr, I've been wrestling this for a bit. I don't know a whole lot about lower level C stuff so I would appreciate some help with this.

I'm attempting to use the pynsca plugin available on git and its kicking out this error:

The command I'm trying to run specific to the pynsca plugin. Once I've declared the NSCANotifier object from the pynsca plugin, I try to run one of its methods:

NSCANotifier.svc_result( "string" , "string" , "string" , "string" )

code:
  File "/usr/lib/python2.7/site-packages/pynsca-1.1-py2.7.egg/pynsca.py", line 139, in svc_result
    iv, timestamp = self._decode_from_server(buf)
  File "/usr/lib/python2.7/site-packages/pynsca-1.1-py2.7.egg/pynsca.py", line 58, in _decode_from_server
    iv, timestamp = struct.unpack(self.fromserver_fmt, bytes)
struct.error: unpack requires a string argument of length 132
Am I supposed to force all of the strings to be 132 bytes long? I'm at a loss.

LuckySevens
Feb 16, 2004

fear not failure, fear only the limitations of our dreams

tef posted:

Cool links

Really good stuff, the sort was particular interesting, I like the way all the considerations are framed, in a 'see: its not so complicated when we break down the problem into smaller, logically separated chunks' kind of way, enlightening to see the thinking itself.

m0nk3yz
Mar 13, 2002

Behold the power of cheese!
If someone writes me a new / updated OP, I'll post it - sorry for my absence, I've been busy.

POKEMAN SAM
Jul 8, 2004
Edit: I'm on Windows

I'm trying to follow this: http://eli.thegreenplace.net/2011/07/03/parsing-c-in-python-with-clang/ but I'm running into a problem with loading the DLL via ctypes. I have a mingw32 compiled DLL, but whenever I call a function that ends up calling a C function in the DLL and passing in an object, I get this error:

ValueError: Procedure called with not enough arguments (4 bytes missing) or wrong calling convention

Trivial functions work, as long as they don't require passing in an object. Changing it to windll.LoadLibrary made it all explode, which makes sense because it's supposed to be a cdll, so using cdll.LoadLibrary should be right.

Any ideas? I've tried Python 2.6 and 2.7 (both 32-bit of course) to no avail...

Edit: It's actually not functions that take in non-boring typed arguments, but ones that return non-boring types that are breaking.

Edit 2: Aha, I have figured it out. Apparently the msys32 clang.dll wasn't cutting it, so I built (using VS2010) my own libclang.dll and everything works peachy keen :)

POKEMAN SAM fucked around with this message at 00:26 on Aug 25, 2011

Computer viking
May 30, 2011
Now with less breakage.

Innocent Bystander posted:

Grr, I've been wrestling this for a bit. I don't know a whole lot about lower level C stuff so I would appreciate some help with this.

I'm attempting to use the pynsca plugin available on git and its kicking out this error:

The command I'm trying to run specific to the pynsca plugin. Once I've declared the NSCANotifier object from the pynsca plugin, I try to run one of its methods:

NSCANotifier.svc_result( "string" , "string" , "string" , "string" )

code:
  File "/usr/lib/python2.7/site-packages/pynsca-1.1-py2.7.egg/pynsca.py", line 139, in svc_result
    iv, timestamp = self._decode_from_server(buf)
  File "/usr/lib/python2.7/site-packages/pynsca-1.1-py2.7.egg/pynsca.py", line 58, in _decode_from_server
    iv, timestamp = struct.unpack(self.fromserver_fmt, bytes)
struct.error: unpack requires a string argument of length 132
Am I supposed to force all of the strings to be 132 bytes long? I'm at a loss.

It's been a while since I played with struct.unpack, but yes - or possibly "at least 132". It is kind of like a reverse printf: It uses a descriptor string to split a chunk of data, and the chunk has to be long enough for all elements in the descriptor.

Grabulon
Jul 25, 2003

Is whoever made skybot the ircbot still active in this thread?

tef
May 30, 2004

-> some l-system crap ->
At a quick pass at updating the OP:




What is Python? (from http://www.python.org)
Python is a dynamic object-oriented programming language that can be used for many kinds of software development. It offers strong support for integration with other languages and tools, comes with extensive standard libraries, and can be learned in a few days. Many Python programmers report substantial productivity gains and feel the language encourages the development of higher quality, more maintainable code.

Official Website: http://www.python.org/
Official Documentation: http://docs.python.org/
Python Quick references: http://rgruet.free.fr/
Semi-Official Python FAQ: http://effbot.org/pyfaq/
Official Python Cheeseshop: http://pypi.python.org/pypi
Official Python Wiki: http://wiki.python.org/moin/
Python development tools, including editors: http://wiki.python.org/moin/DevelopmentTools
Official Planet Python (weblogs): http://planet.python.org/
Unofficial Planet Python (more weblogs): http://www.planetpython.org/
Python Magazine: http://pythonmagazine.com/
Norvig's Infrequently asked questions: http://norvig.com/python-iaq.html - This man exemplifies elegant code. His solutions are just... beautiful.

Python tutorials and free online books:

What version should I use? Python 2.x or 3.x?
http://wiki.python.org/moin/Python2orPython3 - The offical website tells all

Alternative Python interpreter implementations

Python: Myths about Indentations: http://www.secnetix.de/~olli/Python/block_indentation.hawk



m0nk3yz posted:

Why I like python: I enjoy both it's syntax, dynamic (latent) typing, standard library and truly enjoy programming in the language. I've been hacking in python for about four or five years at this point, and I have come to really enjoy the community and ecosystem around the language as well. Python is expressive and while I've run into bits of python code that make me WTF, I've rarely run into a chunk I couldn't read, or understand - you have to go out of your way (or be abusive with say, list comprehensions) to make python unreadable.

spankweasel
Jan 4, 2006

Just some thoughts:

- Maybe add a list of common IDEs? (because this thread gets a ton of questions about IDEs)
- A separate section on web frameworks with links to official sites/SA threads?
- Information about Pycon? (links, what is it, etc.)

tef
May 30, 2004

-> some l-system crap ->
Well Volunteered!

TasteMyHouse
Dec 21, 2006
Since python is often recommended as a beginner's language (especially here in CoC) it'd be nice for there to be a short discussion / link to a discussion about interpreted vs compiled in general, the distinction between CPython and Python itself, etc. I know that stuff kind of confused me when I was looking at python and didn't know poo poo from poo poo.

Scaevolus
Apr 16, 2007

Grabulon posted:

Is whoever made skybot the ircbot still active in this thread?
Yes, I am.

m0nk3yz
Mar 13, 2002

Behold the power of cheese!
OP updated.

spankweasel
Jan 4, 2006

sweet, thanks!

The link to the vim ide page has a trailing ")" which is a 404.

m0nk3yz
Mar 13, 2002

Behold the power of cheese!
fixed

Gothmog1065
May 14, 2009
Alright, I finally found a small project I can do that's basically a ease of use script. The general gist of it is I want to open some programs, move some directories and map a network drive. I'm going to expand and make it nicer eventually, but is there a script out there that has the basics and which modules would be best to use for something like this?

BeefofAges
Jun 5, 2004

Cry 'Havoc!', and let slip the cows of war.

Gothmog1065 posted:

Alright, I finally found a small project I can do that's basically a ease of use script. The general gist of it is I want to open some programs, move some directories and map a network drive. I'm going to expand and make it nicer eventually, but is there a script out there that has the basics and which modules would be best to use for something like this?

Depending on how you're doing things and what OS you're in, you might find these useful:
os
os.path
subprocess
shutil
pywin32

Lurchington
Jan 2, 2003

Forums Dragoon
here's a good stackoverflow answer on calling external programs in python, and why subprocess is a good choice (there are a couple of stdlib modules for doing that and a blind google can be confusing):
http://stackoverflow.com/questions/89228/how-to-call-external-command-in-python/92395#92395

BeefofAges
Jun 5, 2004

Cry 'Havoc!', and let slip the cows of war.

I don't know if anyone will actually find this interesting, but I recently updated my open source hard drive benchmark. It's a script that'll simulate file transfers in Windows, OS X, and Linux as closely as possible to the actual user experience. I had to write a lot of weird hacky code to try to avoid file cache effects and such, like unmounting and remounting drives before each file transfer (obviously this doesn't work if you're using your OS disk or some other volume that can't be unmounted).

I wrote a crappy GUI for the old version of this tool using tkinter, but I'm thinking that if I write a GUI for the new version I'd like to try using PyQT (mostly just as an excuse to learn PyQT).

http://code.google.com/p/copymark2/wiki/Copymark2

Feel free to criticize my code, I wrote some of it a year or so ago when I didn't know as much as I do now.

Gothmog1065
May 14, 2009
Thanks for the leads guys. Looks like the simplest way to open a file is to import subproccess, then subprocess.Popen("App Location"). I know there's more to do with the Popen in subprocess (There's a lot), but that will come later.

The thing I'm working on now is mapping the network drives. One place I went to had this:

pre:
import win32wnet
from win32netcon import RESOURCETYPE_DISK as DISK

drive_letter = "K:"
path = r"\\server\share"
win32wnet.WNetAddConnection2(DISK, drive_letter, path)
I actually added the raw_input() (or have \\\\sever\\share which is stupid). Is that the most efficient way to do that? Basically (for now) my code would look something like this:

pre:
import win32wnet
from win32netcon import RESOURCETYPE_DISK as DISK
dl1, dl2 = "U:", "R:"
path1, path2 = r"\\foo\bar", r"\\foo\bar01"
win32wnet.WNetAddConnection2(DISK, dl1, path1)
win32wnet.WNetAddConnection2(DISK, dl2, path2)
A few things of note: I know I can set that into a loop, even into a function or class. I plan on doing that, even pulling from a text file with various settings, but right now I'm doing this the really basic way while I get some things under my belt. Plus I'm still somewhat unsure about how classes work. There is also no error checking as of yet, that is my next bit of research to see if those paths already exist.

e: Dunno where the hell I picked up that raw_input() at. Thanks tef.

Gothmog1065 fucked around with this message at 15:16 on Sep 1, 2011

tef
May 30, 2004

-> some l-system crap ->
r"a \raw \string"

duck monster
Dec 15, 2004

Its been a very long long time since I've dev'd anything on a windows box, but doesnt python let you do it like c:/blah/blah instead of c:\blah\blah .

Lurchington
Jan 2, 2003

Forums Dragoon
os.path.join makes a lot of this easy, but I do think it's annoying to work with '//<UNC share name>/<folder>/<subfolder>' type stuff since you need to specifically use splitunc

Gothmog1065
May 14, 2009

duck monster posted:

Its been a very long long time since I've dev'd anything on a windows box, but doesnt python let you do it like c:/blah/blah instead of c:\blah\blah .
I have never heard of that. If that's true, that would make things a bit easier.

e: I'll be damned. Just did that in a command prompt. Thanks for that!

duck monster
Dec 15, 2004

Gothmog1065 posted:

I have never heard of that. If that's true, that would make things a bit easier.

e: I'll be damned. Just did that in a command prompt. Thanks for that!

Its a simple little thing, but it goes a hell of a long way to making poo poo x-platform compatible.

Farrok
May 29, 2006

I really really like using VIM to edit python, but problems with autocomplete are starting to get to me. I've set it up like sontek suggests and it has a bunch of great features, but the autocomplete only works well with built in classes. With my own source code or even with third-party libraries installed to site-packages it only completes locally defined variables. I'm aware of the import bug where a failed import can break omnicomplete, so that's definitely not it, and using ctags with my own source only seems to give me the ability to jump to the definition (which is great!) but it doesn't seem to actually add anything to omnicomplete as some people suggested it would in the stackoverflow threads I've looked at.

Anyone have any success with this?


EDIT: Upon further investigation it seems like its some issue with the OSX distributed python or the process of building vim against it. If I use MacPorts python distribution and build vim against that instead, it works as expected. Unfortunately a third party library my current project requires running python in 32-bit mode which I've only gotten to work properly with the OSX distribution of python...I suppose a stopgap solution is to have the libraries I need to use installed to both distributions so I can develope with vim compiled against macports and just run the program with the osx distro. argh!

Farrok fucked around with this message at 05:03 on Sep 8, 2011

Apocadall
Mar 25, 2010

Aren't you the guitarist for the feed dogs?

So after going through 'Learn Python The Hard Way' I was still wanting to learn more about the basics and found a nice set of tutorials on youtube by a guy named Bucky.


Python Programming Tutorial

I personally really like how easy it is to understand them and how it's broken up. Hadn't see it posted in the OP so thought I'd post it for anyone else that could find it a good resource.

Gothmog1065
May 14, 2009

Apocadall posted:

So after going through 'Learn Python The Hard Way' I was still wanting to learn more about the basics and found a nice set of tutorials on youtube by a guy named Bucky.


Python Programming Tutorial

I personally really like how easy it is to understand them and how it's broken up. Hadn't see it posted in the OP so thought I'd post it for anyone else that could find it a good resource.

Aha! That's where I got raw_input() from. Seems it's obsolete now though. Those look like pretty good tutorials for the very beginner, but there's no real way to practice that I noticed.

Apocadall
Mar 25, 2010

Aren't you the guitarist for the feed dogs?

Gothmog1065 posted:

Aha! That's where I got raw_input() from. Seems it's obsolete now though. Those look like pretty good tutorials for the very beginner, but there's no real way to practice that I noticed.

Yeah I used it more to help me remember how to do the basics and how it all works together. From what I was able to learn I think I figured out a small RPG health system and how to expand it. Still working everything out in a flowchart and testing different things though so I could screw it up horribly.

double sulk
Jul 2, 2010

I'm going through Byte of Python and working on learning the syntax and such, and I came across one example where it was giving an error. I realized that there's a difference between 2.7 and 3.0 that I had to use raw_input() vs. input() in order to assign a value to a string variable, and I'm on the 3.0 guide, so that's why I had the problem in the first place. However, I can't seem to fully update to 3.0 for the life of me on OS X Lion, and every guide online to do so is terrible. I have it installed in the applications folder but the shell script seems to do nothing in terms of making /usr/bin/python refer to 3.2 installed in /Library/Frameworks. Any advice?

vikingstrike
Sep 23, 2007

whats happening, captain
Just set up an alias so python points where you want it to.

Captain Capacitor
Jan 21, 2008

The code you say?

Sulk posted:

I'm going through Byte of Python and working on learning the syntax and such, and I came across one example where it was giving an error. I realized that there's a difference between 2.7 and 3.0 that I had to use raw_input() vs. input() in order to assign a value to a string variable, and I'm on the 3.0 guide, so that's why I had the problem in the first place. However, I can't seem to fully update to 3.0 for the life of me on OS X Lion, and every guide online to do so is terrible. I have it installed in the applications folder but the shell script seems to do nothing in terms of making /usr/bin/python refer to 3.2 installed in /Library/Frameworks. Any advice?

Install Homebrew. It's a bit of a pain to try to upgrade the System version, especially if apps are expecting a certain version.

Adbot
ADBOT LOVES YOU

ToxicFrog
Apr 26, 2008


duck monster posted:

Its been a very long long time since I've dev'd anything on a windows box, but doesnt python let you do it like c:/blah/blah instead of c:\blah\blah .

It's a windows thing, not a python thing - in general it'll accept / and \ interchangeably in paths. Very handy.

  • Locked thread