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
Maluco Marinero
Jan 18, 2001

Damn that's a
fine elephant.
I learned from that but I'm told emphatically that there are much better choices out there and it's way out of date.

Adbot
ADBOT LOVES YOU

Vulture Culture
Jul 14, 2003

I was never enjoying it. I only eat it for the nutrients.

Caddrel posted:

I'm not very proficient with python yet, but of the the free books out there Dive Into Python is helping me get up to speed quickly. I think it's best when you are already familiar with similar data structures and OO in other languages, and just need to know how python does it.
Dive Into Python is very old even for a Python 2 reference, and a lot of the conventions in that book (e.g. string formatting) have been deprecated for quite awhile, and it doesn't make any mention of important language features like decorators.

It's an okay thing to teach you the absolute basics, but make sure to read lots of Python code actually written in the past several years if you're going to take it seriously.

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe
I highly recommend against Dive into Python. It's outdated, has terrible examples, and the author has been against making any effort towards keeping it up to date.

The Python 3 version, while newer, makes a lot of mistakes and has bad code examples that would trip up a new user to Python.

WorldIndustries
Dec 21, 2004

Yikes, well I'm glad I found that out.

Delicate Stranger
Nov 16, 2006

Suspicious Dish posted:

Most of your programming days are going to be reading API documentation and figuring out how to glue pieces together, and building that broad understanding and terminology yourself, but maybe diving right in without a lot more hand holding the first time is too sudden.

Yeah, hand holding is the term really. I feel like it's difficult to retain what I'm learning because I end up googling so many questions, that I end up forgetting why I started googling in the first place.

I have to say, though, even getting a really simple terminal program running is such a satisfying feeling.

Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell

Delicate Stranger posted:

I have to say, though, even getting a really simple terminal program running is such a satisfying feeling.

I don't know what its like when you're an old and jaded programmer, but speaking as someone who has been programming for just a few years...I get that feeling every time I grasp a new technique/API/theory.

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe
It's still extremely rare to write something and have it compile and work first-time that I often find myself cursing ccache or similar because I couldn't believe it just worked.

Daynab
Aug 5, 2008

Thermopyle posted:

I don't know what its like when you're an old and jaded programmer, but speaking as someone who has been programming for just a few years...I get that feeling every time I grasp a new technique/API/theory.

I agree with this, I hope this feeling never stops!

Opinion Haver
Apr 9, 2007

The best way to experience this as an old and jaded programmer, I think, is to learn some language unlike anything you've learned. Learning Haskell for me was sort of like learning to program all over again.

Opinion Haver fucked around with this message at 03:45 on Dec 10, 2012

The Gripper
Sep 14, 2004
i am winner

Thermopyle posted:

I don't know what its like when you're an old and jaded programmer, but speaking as someone who has been programming for just a few years...I get that feeling every time I grasp a new technique/API/theory.
For me as an old (young, but old at heart) and jaded programmer the only thing that keeps me interested is finding a new idea to work on. Most of my day-to-day work is maintenance, retrofitting, and tool design which isn't all that interesting or compelling any more.

Outside of work I just have an amazing case of writers block so I spend a lot of time reading about languages and design look for anything that is going to take some actual, solid research that isn't just referring to an API or picking up a new language without making something from it. 90% of the time I just want to sit down and code something but don't have the faintest idea of where to start.

Currently that journey has taken me into the depths of 3D graphics/game engines, and I can't see myself coming out of this as a whiz-kid any time soon.

Haystack
Jan 23, 2005





Thermopyle posted:

Googlin' leads me to believe theres some plugins (or whatever you call them) for Flask to automate creating admin pages...are any of those any good?

It's not flask based, but Kotti is a nice, thin CMS built on top of pyramid. It might hit your "does stuff for you, but not a nightmare to subvert" sweet-spot.

Vote Republican
Jul 7, 2012
e: discussed earlier.

Dren
Jan 5, 2001

Pillbug

The Gripper posted:

For me as an old (young, but old at heart) and jaded programmer the only thing that keeps me interested is finding a new idea to work on. Most of my day-to-day work is maintenance, retrofitting, and tool design which isn't all that interesting or compelling any more.

Outside of work I just have an amazing case of writers block so I spend a lot of time reading about languages and design look for anything that is going to take some actual, solid research that isn't just referring to an API or picking up a new language without making something from it. 90% of the time I just want to sit down and code something but don't have the faintest idea of where to start.

Currently that journey has taken me into the depths of 3D graphics/game engines, and I can't see myself coming out of this as a whiz-kid any time soon.

Have you tried project euler?

Lately I've been toying with a scrabble/words with friends solver.

I find implementing algorithms, even already solved ones, more interesting than hooking together a bunch of different APIs in order to do something like display output on a web page.

Sylink
Apr 17, 2004

Project Euler is cool but my only complaint about it is that a lot of the problems are pretty hard until you figure out the mathematical trick to them which reduces computation time.

Some can be bruteforced but the harder ones are pretty impossible in the lifespan of the universe unless you know exactly what they are getting at. So its more of a math game than anything.

Jewel
May 2, 2009

Sylink posted:

Project Euler is cool but my only complaint about it is that a lot of the problems are pretty hard until you figure out the mathematical trick to them which reduces computation time.

Some can be bruteforced but the harder ones are pretty impossible in the lifespan of the universe unless you know exactly what they are getting at. So its more of a math game than anything.

Yeah that's my main gripe with it. But I guess most code sites like that are math based. Or riddle based. Or stuff like "figure out how text is crypotgraphically hidden in this image" v:shobon:v

Yay
Aug 4, 2007
Reddit has /r/dailyprogrammer, which sometimes has interesting problems, not all of which are heavily "mathsy", and often come in multiple difficulties.

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe
I help out on #python and we have a "NO PROJECT EULER" rule. We're all bored of solving the same problems, and yeah, most of them are math problems, not computation issues. They're fun math problems, but don't illusion yourself into thinking they'll make you a better day-to-day programmer.

fart simpson
Jul 2, 2005

DEATH TO AMERICA
:xickos:

I kind of like project Euler when I'm learning the syntax of a new language. I know all the solutions to the first 10 problems or so, which is all I generally do. I do think it can be helpful to type them in anyway in a new language to get a feel for it.

raminasi
Jan 25, 2005

a last drink with no ice
How the hell do I make a beta distribution :saddowns:

Python code:
>>> from scipy.stats.distributions import beta
>>> beta.pdf(0.1, a=2.0, b=3.0)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\python27\lib\site-packages\scipy\stats\distributions.py", line 1297, in pdf
    place(output,cond,self._pdf(*goodargs) / scale)
TypeError: _pdf() takes exactly 4 arguments (2 given)
The documentation is not terribly helpful.

fritz
Jul 26, 2003

GrumpyDoctor posted:

How the hell do I make a beta distribution :saddowns:

Python code:
>>> from scipy.stats.distributions import beta
>>> beta.pdf(0.1, a=2.0, b=3.0)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\python27\lib\site-packages\scipy\stats\distributions.py", line 1297, in pdf
    place(output,cond,self._pdf(*goodargs) / scale)
TypeError: _pdf() takes exactly 4 arguments (2 given)
The documentation is not terribly helpful.

Take out the a= b= stuff.
code:
In [13]: from scipy.stats.distributions import beta

In [14]: beta.pdf(0.1,2.0,3.0)
Out[14]: 0.9720000000000002

raminasi
Jan 25, 2005

a last drink with no ice

fritz posted:

Take out the a= b= stuff.
code:
In [13]: from scipy.stats.distributions import beta

In [14]: beta.pdf(0.1,2.0,3.0)
Out[14]: 0.9720000000000002

Okay, but what are those parameters? Are they alpha and beta but I'm not allowed to call them that? And where am I supposed to be looking this up?

OnceIWasAnOstrich
Jul 22, 2006

e: wrong thread

Vulture Culture
Jul 14, 2003

I was never enjoying it. I only eat it for the nutrients.

MeramJert posted:

I kind of like project Euler when I'm learning the syntax of a new language. I know all the solutions to the first 10 problems or so, which is all I generally do. I do think it can be helpful to type them in anyway in a new language to get a feel for it.
This is how I learned Erlang and re-learned Python, actually.

fritz
Jul 26, 2003

GrumpyDoctor posted:

Okay, but what are those parameters? Are they alpha and beta but I'm not allowed to call them that? And where am I supposed to be looking this up?

First parameter is points to evaluate the pdf at, second are a&b.

From beta? :

pre:
A beta continuous random variable.

Continuous random variables are defined from a standard form and may
require some shape parameters to complete its specification.  Any
optional keyword parameters can be passed to the methods of the RV
object as given below:

Methods
-------
rvs(a, b, loc=0, scale=1, size=1)
    Random variates.
pdf(x, a, b, loc=0, scale=1)
    Probability density function.
logpdf(x, a, b, loc=0, scale=1)
    Log of the probability density function.
cdf(x, a, b, loc=0, scale=1)
    Cumulative density function.
logcdf(x, a, b, loc=0, scale=1)
    Log of the cumulative density function.
...
It's not very clear.


ETA: and I don't know why a= b= don't work.

raminasi
Jan 25, 2005

a last drink with no ice

fritz posted:

First parameter is points to evaluate the pdf at, second are a&b.

From beta? :

pre:
A beta continuous random variable.

Continuous random variables are defined from a standard form and may
require some shape parameters to complete its specification.  Any
optional keyword parameters can be passed to the methods of the RV
object as given below:

Methods
-------
rvs(a, b, loc=0, scale=1, size=1)
    Random variates.
pdf(x, a, b, loc=0, scale=1)
    Probability density function.
logpdf(x, a, b, loc=0, scale=1)
    Log of the probability density function.
cdf(x, a, b, loc=0, scale=1)
    Cumulative density function.
logcdf(x, a, b, loc=0, scale=1)
    Log of the cumulative density function.
...
It's not very clear.


ETA: and I don't know why a= b= don't work.

Where did you find that, though?

fritz
Jul 26, 2003

GrumpyDoctor posted:

Where did you find that, though?

If you use ipython, just type beta? at the prompt, if you use the regular python interpreter, stop doing that and use ipython, but if you can't then do "print beta.__doc__"

Captain Capacitor
Jan 21, 2008

The code you say?
I wish IPython would stop being a dick and play nice with my virtualenvs.

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe
What about using bpython instead?

raminasi
Jan 25, 2005

a last drink with no ice
Another question: does anyone know why shutil.rmtree might be failing to delete a directory that exists with "No such file or directory," even when I set ignore_errors=True? I assume it has something to do with it being used with multiprocessing because it's not consistent or anything.

(I have a third-party library that insists on creating a directory in my current working directory as part of its operation and I want each worker process to clean up its mess when it's done.)

Titan Coeus
Jul 30, 2007

check out my horn
The Rosalind project has some good problems to practice programming on. I have done a few of them and didn't need any biology background. I can't speak for the higher level stuff.

BeefofAges
Jun 5, 2004

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

GrumpyDoctor posted:

Another question: does anyone know why shutil.rmtree might be failing to delete a directory that exists with "No such file or directory," even when I set ignore_errors=True? I assume it has something to do with it being used with multiprocessing because it's not consistent or anything.

(I have a third-party library that insists on creating a directory in my current working directory as part of its operation and I want each worker process to clean up its mess when it's done.)

Are you sure you're passing it the right path? Are you giving it a relative path or an absolute path?

duck monster
Dec 15, 2004

Note, not loving up indenting here. An experiment;-

code:
#A javascripty sort of declaration
class Foo:
    pass

#An instance of it
x = Foo()

#Lets assign it some functions
def func(self,param):
    self._storeval = param
Foo.store = func

def func(self):
    print "It was ",self._storeval
Foo.output = func

#Lets test it.
x.store('bar')
x.output()
It was bar!
Why one would code like this, I dont know, but hey, it works.

Daynab
Aug 5, 2008

I'm kind of in a tough spot right now :( I posted before I'm nearly done with LPTHW though the book dumped a bunch of stuff in the last 3-4 lessons of it I have a hard time comprehending so early, like setup scripts and unit testing. (It doesn't help that the book basically says "google everything" at this point.)

So I figure I would learn a bit by making some really simple apps, the problem is whenever I try to do something interesting (like with an interface) I kind of only half-understand what I'm reading, just not enough to absorb it and recreate it by myself.

It's like I'm stuck between knowing the really basic stuff by heart but not being comfortable doing anything else or being able to learn the next stuff.

I'm really not sure what to do at this point.

Jewel
May 2, 2009

duck monster posted:

Note, not loving up indenting here. An experiment;-

Why one would code like this, I dont know, but hey, it works.

Did someone say, weird obtuse code that tests the boundaries of python and still works? I made this a while ago to see something.

Python code:
class Human():
    def speak(self, text):
        print "I am saying",text+"!"

classn = "Human"
funcn = "speak"

getattr(globals()[classn](), funcn, None)("words words words")
OUTPUT:
pre:
I am saying words words words!
Now this code is terrible, yes. But I was intrigued, so I built upon that idea.

This led to probably the absolute worst code I've ever made :getin:

Python code:
parentClass = {
            'name':'Feline',
            'parent':object,
            'x':0,
            'y':0
            }

childClass = {
            'name':'Cougar',
            'parent':"Feline",
            'x':70,
            'y':30,
            }

#####

globals()[parentClass["name"]] = type(
        parentClass["name"],
        (parentClass["parent"],),
        dict(
            x = parentClass["x"],
            y = parentClass["y"],
            get_x = lambda self:self.x,
            get_y = lambda self:self.y
        )
    )
    

globals()[childClass["name"]]= type(
        childClass["name"],
        (globals()[childClass["parent"]],),
        dict(
            x = childClass["x"],
            y = childClass["y"]
        )
    )

coug = globals()[childClass["name"]]()
print "Coug is of class:",coug.__class__.__name__
print "Cougar Coords:", coug.get_x(), coug.get_y()
coug.x += 5
coug.y += 3
print "New Cougar Coords:", coug.get_x(), coug.get_y()
OUTPUT:
pre:
Coug is of class: Cougar
Cougar Coords: 70 30
New Cougar Coords: 75 33

duck monster
Dec 15, 2004

Daynab posted:

I'm kind of in a tough spot right now :( I posted before I'm nearly done with LPTHW though the book dumped a bunch of stuff in the last 3-4 lessons of it I have a hard time comprehending so early, like setup scripts and unit testing. (It doesn't help that the book basically says "google everything" at this point.)

So I figure I would learn a bit by making some really simple apps, the problem is whenever I try to do something interesting (like with an interface) I kind of only half-understand what I'm reading, just not enough to absorb it and recreate it by myself.

It's like I'm stuck between knowing the really basic stuff by heart but not being comfortable doing anything else or being able to learn the next stuff.

I'm really not sure what to do at this point.

Think up some crazy apps and make them. Its the only way to learn.

"Do or do not. There is no Try"
- Kurt Kobain 1943-1993

Maluco Marinero
Jan 18, 2001

Damn that's a
fine elephant.
Yep, took me a year but I made a thing from zero programming understanding, because it was something I wanted to make and was willing to sacrifice nights to make it happen. Just grab frameworks and toolkits that will help you make the thing you WANT to make and you'll learn plenty.

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe

Daynab posted:

I'm really not sure what to do at this point.

Make a dumb utility that might help you solve a problem. If you have to do a tedious calculation, or some repetitive task, try writing a special-purpose program to help you out. I learned Python by writing programs that did my high school algebra homework for me.

duck monster
Dec 15, 2004

Man, why can't I monkey patch the base class :(

code:
>>> def func(self, **kwargs):
...     return "buttes"
... 
>>> object.__str__ = func
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: can't set attributes of built-in/extension type 'object'
... ought break python in very comical ways

But it doesn't :argh:

The fucken thing would probably work on ruby.

tef
May 30, 2004

-> some l-system crap ->
https://gist.github.com/295200 you can use ctypes to monkeypatch cpython :eng99:

Adbot
ADBOT LOVES YOU

tef
May 30, 2004

-> some l-system crap ->

duck monster posted:

Note, not loving up indenting here. An experiment;-

[code]
#A javascripty sort of declaration
class Foo:
pass

#An instance of it
x = Foo()

#Lets assign it some functions
def func(self,param):
self._storeval = param
Foo.store = func

nb this works because you assign the function to the class, rather than an instance.


quote:

Why one would code like this, I dont know, but hey, it works.

It's kinda useful.

quote:

>>> class Foo(object):
... def butt(self):
... print "butt"
... lol=butt
...
>>> Foo().lol()

Every so often you will encounter a class where you want to compose it from other bits, but without using inheritance.

  • Locked thread