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
Lurchington
Jan 2, 2003

Forums Dragoon

JetsGuy posted:

I didn't have time before work to check my home computer for that Runge-Kutter, but I promise I'll post it tonight.


out of curiosity, what benefits does the csv reader give you over doing something like:

code:
with file("datafile.csv", "r") as f:
    data = f.readlines()

x = []
y = []
for line in data:
    line = line.split(",")
    x.append(float(line[0]))
    y.append(float(line[1]))
Does the CSV package automatically do this poo poo for you? I've never really spent much time with it.

yeah, and also handles situations where your code happens to blow up. For example, quotes strings that have a comma in them"

Also, getting to refer to a refer as a dictionary with keys as the csv header row. Pretty sweet.

Thern posted:

I just started looking into csv module for something I'm working on, so I'm curious. Is there a reason that you couldn't use the writerows method instead?

probably just user writerows unless you need to skip certain lines or something

Adbot
ADBOT LOVES YOU

the
Jul 18, 2004

by Cowcaster
Working on my Runge Kutte here:

Python code:
import numpy
import pylab
 
N = 10.
 
R = 0.025
rhonot = 1.0*10**10
wnot = 1.0*10**-3
L = 0.1
Toff = 8.0*10**-11
timer = 0. 
h = 2.*L/N
mu0 = 4*numpy.pi*10**-7
e0 = 8.85*10**-12
dt = (0.25*h)/(1/numpy.sqrt(mu0*e0))
 
grid = numpy.arange(0,2*L+.001,h)
 
x = y = z = numpy.zeros(grid.size)
 
for i in range(0,grid.size):
        x[i] = -L + i*h
        y[i] = -L + i*h
        z[i] = -L + i*h

ex = ey = ez = bx = by = bz = ehx = ehy = ehz = bhx = bhy = bhz = J = numpy.zeros([grid.size, grid.size, grid.size])


for i in range(1,x.size-1):
        for j in range(1,x.size-1):
            for k in range(1,x.size-1):
                if numpy.sqrt(x[i]**2 + y[j]**2 + z[k]**2) <= R:
                        J[i,j,k] = (1./2)*(1 + numpy.cos(numpy.pi*numpy.sqrt(x[i]**2 + y[j]**2 + z[k]**2)/R))
                else:
                        J[i,j,k] = 0.
                
                ehx[i,j,k] = ex[i,j,k] + (dt/(4*mu0*e0))(bx[i,j+1,k] - bx[i,j-1,k] - bx[i,j,k+1] + bx[i,j,k-1]) - (dt/(2.*e0))*J[i,j,k]
                ehy[i,j,k] = ey[i,j,k] + (dt/(4*mu0*e0))(by[i,j+1,k] - by[i,j-1,k] - by[i,j,k+1] + by[i,j,k-1]) - (dt/(2.*e0))*J[i,j,k]
                ehz[i,j,k] = ez[i,j,k] + (dt/(4*mu0*e0))(bz[i,j+1,k] - bz[i,j-1,k] - bz[i,j,k+1] + bz[i,j,k-1]) - (dt/(2.*e0))*J[i,j,k]

At the third to bottom line I'm getting the error: "numpy.float64' object is not callable". I'm pretty sure it's happening on the [bx....] portion

I can't figure out what this means.

I know in console I can totally type bx[1,2,1], bx[0,1,0], etc.. and get values out.

fart simpson
Jul 2, 2005

DEATH TO AMERICA
:xickos:

Thermopyle posted:

Hmm, I think I disagree. It seems very clear to me what the comprehension is doing and ever so slightly obtuse what map is doing there. However, I can't say for sure if that is because I use list comprehensions 100 times more than map, or if it's just a difference in the way we understand code we read.

However, like I said earlier, it's not a big deal either way.

Maybe it's just a mental difference in the way we're reading it. This is kind of what I'm talking about :


fritz posted:

Not a lambda, but:
f = open("x.csv","w")
cw = csv.writer(f)
map(cw.writerow,data)
f.close()

DARPA
Apr 24, 2005
We know what happens to people who stay in the middle of the road. They get run over.

JetsGuy posted:

I didn't have time before work to check my home computer for that Runge-Kutter, but I promise I'll post it tonight.


out of curiosity, what benefits does the csv reader give you over doing something like:

code:
with file("datafile.csv", "r") as f:
    data = f.readlines()

x = []
y = []
for line in data:
    line = line.split(",")
    x.append(float(line[0]))
    y.append(float(line[1]))
Does the CSV package automatically do this poo poo for you? I've never really spent much time with it.

You would fail horribly to parse this CSV data:

"John", "Doe, Jr.","123 Fake Street
Chicago, IL","555-555-5555, ext 5555","I really liked your site, but it seems to break when I upload a csv file containing commas."

Emacs Headroom
Aug 2, 2003

the posted:

Working on my Runge Kutte here:

Python code:
(dt/(4*mu0*e0))(bx[i,j+1,k] - bx[i,j-1,k] - bx[i,j,k+1] + bx[i,j,k-1]) - (dt/(2.*e0))
At the third to bottom line I'm getting the error: "numpy.float64' object is not callable". I'm pretty sure it's happening on the [bx....] portion
Classic. You meant to do:
Python code:
(dt/(4*mu0*e0)) * (bx[i,j+1,k] - bx[i,j-1,k] - bx[i,j,k+1] + bx[i,j,k-1]) - (dt/(2.*e0))

Opinion Haver
Apr 9, 2007

a lovely poster posted:

Because writing the shortest lines possible is not really a goal for most software developers. I would use the first because in the case of someone else editing my code it would be a lot easier to understand.

operator.itemgetter(0) looks like a python statement, anyone with two weeks of python would understand what's going on

lambda x: x[0] might as well be a different language as far as a lot of developers go

Now, it's important to be concise and clear, but I'm unconvinced that it's worth shaving off five characters

Maybe it's just because I've been doing a lot of functional programming lately, but I always found the operator stuff incredibly clunky. And if you need to chain them, it's basically unreadable.

a lovely poster
Aug 5, 2011

by Pipski

yaoi prophet posted:

Maybe it's just because I've been doing a lot of functional programming lately, but I always found the operator stuff incredibly clunky. And if you need to chain them, it's basically unreadable.

Yeah, I mean, ultimately the correct answer is to choose the more readable one. If you're working with a team of python developers that lambda is easier for, by all means go for it. I just don't think statement length should really be a factor when you're talking about a difference of five characters. In fact, many times code is better when it's longer.

JetsGuy
Sep 17, 2003

science + hockey
=
LASER SKATES

Lurchington posted:

yeah, and also handles situations where your code happens to blow up. For example, quotes strings that have a comma in them"

Also, getting to refer to a refer as a dictionary with keys as the csv header row. Pretty sweet.

DARPA posted:

You would fail horribly to parse this CSV data:

"John", "Doe, Jr.","123 Fake Street
Chicago, IL","555-555-5555, ext 5555","I really liked your site, but it seems to break when I upload a csv file containing commas."

Both great points.

I'm just very used to two types of people handling my code:

1) Me
2) Fellow scientists like me who will also run it from the command line with their own data files

I guess it's not great practice, but the codes we hand each other very much tend to require a very specific format, and it's on you if you refuse to read the header and give the routine something else.

Personally, I just use tab/space delimiters, but I can see the point in needing commas for datafiles with strings that have any sort of complexity.

Thern
Aug 12, 2006

Say Hello To My Little Friend
Just be thankful you never had to parse data from a source that wasn't in your control, and could change format on the whim of the developers in charge of that process, who also felt no obligation to notify you of said changes.

JetsGuy
Sep 17, 2003

science + hockey
=
LASER SKATES

Thern posted:

Just be thankful you never had to parse data from a source that wasn't in your control, and could change format on the whim of the developers in charge of that process, who also felt no obligation to notify you of said changes.

Yeah, I understand what I do is very much "scientific programming" and when I get handed a data file that's a weird delimiter I just run a "replace all" in emacs and *poof* its how I like it. The worst I've had to do is a quick FITS -> ASCII in fv or resurrecting some awful IDL .sav file or something.

JetsGuy
Sep 17, 2003

science + hockey
=
LASER SKATES
So do you still need that Runge-Kutter of mine? Because it looks to me like you solved it. I am positive mine wasn't 3d, but I'll post it as promised if you still want it.

Hed
Mar 31, 2004

Fun Shoe

JetsGuy posted:

I didn't have time before work to check my home computer for that Runge-Kutter, but I promise I'll post it tonight.


out of curiosity, what benefits does the csv reader give you over doing something like:

code:
with file("datafile.csv", "r") as f:
    data = f.readlines()

x = []
y = []
for line in data:
    line = line.split(",")
    x.append(float(line[0]))
    y.append(float(line[1]))
Does the CSV package automatically do this poo poo for you? I've never really spent much time with it.

csv.DictReader and DictWriter are awesome.

evensevenone
May 12, 2001
Glass is a solid.
How bad is it to instantiate things in a module? I.e. I have a module that has multiple classes that all need to see an object, and for better or worse it needs to be a singleton. I could either pass the reference around endlessly or just instantiate it in the base namespace and it it'd visible to everything within the module.

the
Jul 18, 2004

by Cowcaster

JetsGuy posted:

So do you still need that Runge-Kutter of mine? Because it looks to me like you solved it. I am positive mine wasn't 3d, but I'll post it as promised if you still want it.

Not sure. I'm having problems now where my vectors are blowing up, so I'm trying to figure out why that's happening. It's most likely an error in the equation somewhere that I'm not seeing. If you have a pastebin post of your code I'd sure take a look at it, thanks.

fritz
Jul 26, 2003

Thern posted:

I just started looking into csv module for something I'm working on, so I'm curious. Is there a reason that you couldn't use the writerows method instead?

In this particular case, no, not really, it was just the first example of a map that I had open in the file I was editing at the time.

a lovely poster posted:

operator.itemgetter(0) looks like a python statement, anyone with two weeks of python would understand what's going on

It looks like a function call to me, and it's not at all clear that it's returning something that'll be itself callable.



I also do lambdas if I'm doing a sort with a complicated comparison function, forex L.sort(key = lambda x: x[1]/x[2]) to sort a list based on the ratio of two fields.

Nippashish
Nov 2, 2005

Let me see you dance!

a lovely poster posted:

Because writing the shortest lines possible is not really a goal for most software developers. I would use the first because in the case of someone else editing my code it would be a lot easier to understand.

operator.itemgetter(0) looks like a python statement, anyone with two weeks of python would understand what's going on

lambda x: x[0] might as well be a different language as far as a lot of developers go

Now, it's important to be concise and clear, but I'm unconvinced that it's worth shaving off five characters

My point wasn't that optimizing for line length is a worthwhile goal in and of itself, my point was that I see many advantages to the lambda version and one of them is that it's shorter. I don't agree that the itemgetter version is easier to understand, unless you simply don't know what lambda does, but the idea that you should avoid language features because your coworkers don't understand the language they're using is silly.

As fritz mentions, it's also not clear apriori that operator.itemgetter(0) returns a callable object.

JetsGuy
Sep 17, 2003

science + hockey
=
LASER SKATES

the posted:

Not sure. I'm having problems now where my vectors are blowing up, so I'm trying to figure out why that's happening. It's most likely an error in the equation somewhere that I'm not seeing. If you have a pastebin post of your code I'd sure take a look at it, thanks.

Keep in mind this was for a HW assignment almost 7 years ago when I was maybe 2-3 weeks into learning any computer language in a serious manner. I look at this code, and holy gently caress I'd write this much differently nowadays. Also, I had to output every iteration, that's why all the printing. In any case, the basics of it seem to be there... hope it's useful.

code:
import matplotlib
matplotlib.interactive(False)
from pylab import *
import numpy as n
file=file("rangekutter.txt","w")

dt=2*math.pi/100
t=arange(0,2*math.pi+dt,dt) #had to add the extra dt so it would
                            #include 2pi as python is non-inclusive
file.write("***************************************\n")
file.write("*********RUNGE-KUTTER METHOD***********\n")
file.write("***************************************\n")

x = n.zeros([101])  #makes array of 0 for x
v = n.zeros([101])  #makes array of 0 for v
v[0]=1       #puts a 1 for init v

for i in range(len(x)):
    if i<100:
        k1x=dt*v[i]
        k1v=dt*(-x[i])
        k2x=dt*(v[i]+k1v/2)
        k2v=dt*(-x[i]-k1x/2)
        x[i+1]=x[i]+k2x
        v[i+1]=v[i]+k2v
        file.write("for the indcie number\n")
        file.write(repr(i))
        file.write("\n")
        file.write("error in x (value - sin[t])\n")
        file.write(repr(x[i]-sin(t[i])))
        file.write("\n")
        file.write("error in v (value - cos[t])\n")
        file.write(repr(v[i]-cos(t[i])))
        file.write("\n\n") 
        
file.write("Range-Kutter method Complete\n")
file.write("The NEW x array is:\n")
file.write(repr(x))
file.write("\n")
file.write("the NEW v array is:\n")
file.write(repr(v))
file.close()
plot(t, x,'.g',label='x(t)')
plot(t, v,'.b',label='v(t)')
plot(t,sin(t),'-r',label='sin(t)')
plot(t,cos(t),'-k',label='cos(t)')
title('Runge-Kutter Method')
legend()
savefig('RK.png', dpi=300)
show()
Also, gently caress me for ever using pylab, what the gently caress was I thinking? AND import * is the dumbest thing... don't do it. :-p

I can guarantee it works for sin/cos! :v:

JetsGuy fucked around with this message at 06:01 on Mar 14, 2013

Love Stole the Day
Nov 4, 2012
Please give me free quality professional advice so I can be a baby about it and insult you
Hey again,

Back on page 247 or whatever I asked about a library or module or something for me to expedite the process of making an IRC bot.

I decided to go with "ircutils": http://dev.guardedcode.com/docs/ircutils/index.html

It was exactly what I was looking for and it's a very small, well-enough documented library and a good enough tutorial to do what you need to do.

Just wanted to share here in case anyone from the future searches this old post of mine here looking for how to make an IRC bot.

PS: Hi, future goon!

the
Jul 18, 2004

by Cowcaster
Something weird is going on. I have this statement:

Python code:
if (numpy.sqrt(x[i]**2 + y[j]**2 + z[k]**2) <= R) and (timer <= Toff):
	    Jhx[i,j,k] = (1./2)*(1 + numpy.cos(numpy.pi*numpy.sqrt(x[i]**2 + y[j]**2 + z[k]**2)/R))*(x[i]-y[j])
	    Jhy[i,j,k] = (1./2)*(1 + numpy.cos(numpy.pi*numpy.sqrt(x[i]**2 + y[j]**2 + z[k]**2)/R))*(x[i]-y[j])
        Jhz[i,j,k] = 0
        print (1./2)*(1 + numpy.cos(numpy.pi*numpy.sqrt(x[i]**2 + y[j]**2 + z[k]**2)/R))*(x[i]-y[j])
        print Jhx[i,j,k]
                                       
else:
        Jhx[i,j,k] = 0.
        Jhy[i,j,k] = 0.
        Jhz[i,j,k] = 0.
That first print command? It prints out a nonzero value. That second one? It prints out zeros. Yet I make the second one equal to the first in line 2. :psyduck:

the fucked around with this message at 19:04 on Mar 14, 2013

Xerophyte
Mar 17, 2008

This space intentionally left blank

the posted:

Something weird is going on. I have this statement:

Python code:
if (numpy.sqrt(x[i]**2 + y[j]**2 + z[k]**2) <= R) and (timer <= Toff):
	    Jhx[i,j,k] = (1./2)*(1 + numpy.cos(numpy.pi*numpy.sqrt(x[i]**2 + y[j]**2 + z[k]**2)/R))*(x[i]-y[j])
	    Jhy[i,j,k] = (1./2)*(1 + numpy.cos(numpy.pi*numpy.sqrt(x[i]**2 + y[j]**2 + z[k]**2)/R))*(x[i]-y[j])
        Jhz[i,j,k] = 0
        print (1./2)*(1 + numpy.cos(numpy.pi*numpy.sqrt(x[i]**2 + y[j]**2 + z[k]**2)/R))*(x[i]-y[j])
        print Jhx[i,j,k]
                                       
else:
        Jhx[i,j,k] = 0.
        Jhy[i,j,k] = 0.
        Jhz[i,j,k] = 0.
That first print command? It prints out a nonzero value. That second one? It prints out zeros. Yet I make the second one equal to the first in line 2. :psyduck:
If you're still initializing using something like
Python code:
ex = ey = ez = bx = by = bz = ehx = ehy = ehz = bhx = bhy = bhz = J = numpy.zeros([grid.size, grid.size, grid.size])
then you may wish to reconsider. You're actually making all these variables refer to the same array. Presumably Jhx = Jhz was declared at some point and the assignment Jhz[i,j,k] = 0 is therefore also Jhx[i,j,k] = 0.

the
Jul 18, 2004

by Cowcaster

Xerophyte posted:

If you're still initializing using something like
Python code:
ex = ey = ez = bx = by = bz = ehx = ehy = ehz = bhx = bhy = bhz = J = numpy.zeros([grid.size, grid.size, grid.size])
then you may wish to reconsider. You're actually making all these variables refer to the same array. Presumably Jhx = Jhz was declared at some point and the assignment Jhz[i,j,k] = 0 is therefore also Jhx[i,j,k] = 0.

Thanks. I've been told that's dangerous to do before. And I should have remembered that.

aeverous
Nov 13, 2009
Man some of you guys are so good at reading other peoples code that's just mathematically impenetrable to me, I guess that comes with years of experience. As a self taught programmer though I think I might be hitting a bit of a wall, I have trouble designing efficient algorithms in particular, you good programmers seem to use some mathematical knowledge to make something efficient where I would make a huge set of nested loops. Might not be the thread for it but I realised this while reading this page, can someone recommend a book that contains the maths necessary to be a good programmer but is accessible? Like not necessarily a college student's maths textbook, but more in depth than high school level maths?

a lovely poster
Aug 5, 2011

by Pipski

aeverous posted:

Man some of you guys are so good at reading other peoples code that's just mathematically impenetrable to me, I guess that comes with years of experience. As a self taught programmer though I think I might be hitting a bit of a wall, I have trouble designing efficient algorithms in particular, you good programmers seem to use some mathematical knowledge to make something efficient where I would make a huge set of nested loops. Might not be the thread for it but I realised this while reading this page, can someone recommend a book that contains the maths necessary to be a good programmer but is accessible? Like not necessarily a college student's maths textbook, but more in depth than high school level maths?

I would really consider checking out edx's introduction to python programming class.

https://www.edx.org/courses/MITx/6.00x/2013_Spring/about

They go into some pretty good depth regarding popular algorithms and ways to use them.

evensevenone
May 12, 2001
Glass is a solid.

the posted:

Thanks. I've been told that's dangerous to do before. And I should have remembered that.

If you really think about the Python object model and what = is actually doing, it really helps to avoid making those kind of mistakes. If you aren't clear on it right now, it's going to really bit you in the rear end later.

Casyl
Feb 19, 2012

a lovely poster posted:

I would really consider checking out edx's introduction to python programming class.

https://www.edx.org/courses/MITx/6.00x/2013_Spring/about

They go into some pretty good depth regarding popular algorithms and ways to use them.

I'll second this. I'm a beginning programmer and did this class last year and it was quite good. They do teach a section on Big O notation and efficient coding.

Opinion Haver
Apr 9, 2007

What's the idiomatic way for initializing a bunch of variables to the same value without that kind of sharing?

leterip
Aug 25, 2004

yaoi prophet posted:

What's the idiomatic way for initializing a bunch of variables to the same value without that kind of sharing?

I might do something like

Python code:
x, y, z = (thinger() for _ in xrange(3))
I'd be interested to hear other options.

Munkeymon
Aug 14, 2003

Motherfucker's got an
armor-piercing crowbar! Rigoddamndicu𝜆ous.



yaoi prophet posted:

What's the idiomatic way for initializing a bunch of variables to the same value without that kind of sharing?

Python code:
a, b, c = (0,) * 3
Edit: lost track of the original problem. That won't work for a list.
Edit 2:
Python code:
a,b,c = (map(np.zeros, ([1,1],) * 3))
:v:

Munkeymon fucked around with this message at 22:27 on Mar 14, 2013

Jose Cuervo
Aug 25, 2004
I am trying to use a statistical test in SciPy but I am not sure I understand how to call it correctly. The test documentation is located here: Fligner's test documentation

The following code runs just fine (where vfb_dataList and hsp_dataList are both Python lists):
Python code:
scipy.stats.fligner(vfb_dataList, hsp_dataList)
However the following code
Python code:
scipy.stats.fligner(vfb_dataList, hsp_dataList, 'median')
produces the following error:
Python code:
TypeError: unsupported operand type(s) for -: 'numpy.ndarray' and 'numpy.string_'
I think it is treating 'median' as another data set, but I don't know why. Any thoughts on what I am doing incorrectly?

Hammerite
Mar 9, 2007

And you don't remember what I said here, either, but it was pompous and stupid.
Jade Ear Joe

Love Stole the Day posted:

Hey again,

Back on page 247 or whatever I asked about a library or module or something for me to expedite the process of making an IRC bot.

I decided to go with "ircutils": http://dev.guardedcode.com/docs/ircutils/index.html

It was exactly what I was looking for and it's a very small, well-enough documented library and a good enough tutorial to do what you need to do.

Just wanted to share here in case anyone from the future searches this old post of mine here looking for how to make an IRC bot.

PS: Hi, future goon!

I have a project that I kind of go back to every often that uses this too, I agree it gives you a nice way to build simple IRC bots. Watch out if Python3 support matters to you though, it isn't compatible and doesn't appear to be actively developed any longer.

fritz
Jul 26, 2003

Jose Cuervo posted:

I am trying to use a statistical test in SciPy but I am not sure I understand how to call it correctly. The test documentation is located here: Fligner's test documentation


I think it is treating 'median' as another data set, but I don't know why. Any thoughts on what I am doing incorrectly?

Maybe try "center = 'median' "?

the
Jul 18, 2004

by Cowcaster
Let's say I have a timer T that increments in DT and runs while T < TOFF.

Like an example would be T = 0, DT = 3, TOFF = 11. So T = 0, 3, 6, 9.. then stops after the next DT.

I want to store some values when T is approximately halfway to TOFF, and then stop before the next DT. But I won't know what that exact number is (or it might not get to literally 50% of TOFF). How do I do this?

I'm thinking something like:

Python code:
if (T > TOFF/2) and (T < TOFF/2 + DT)

Emacs Headroom
Aug 2, 2003
I'd probably take the interval around [TOFF/2 - DT/2, TOFF/2 + DT/2]. Since this interval is DT across, you'll have exactly one index inside of it:
Python code:
if (T-TOFF/2 >= -DT/2) and (T-TOFF/2 < DT/2)
You'd still have a (small) chance of catching more than one entry because of round-off error though.

the
Jul 18, 2004

by Cowcaster
Can I use numpy.around() to fix that?

evensevenone
May 12, 2001
Glass is a solid.
How about just if (t>toff/2) and (t-dt<toff/2) ? It isn't centered but that shouldn't really matter.

Jose Cuervo
Aug 25, 2004

fritz posted:

Maybe try "center = 'median' "?

Yep that worked. Did something in the way the documentation was written point you towards doing that?

fritz
Jul 26, 2003

Jose Cuervo posted:

Yep that worked. Did something in the way the documentation was written point you towards doing that?

Yeah, the "sample1, sample2, ..." in the documentation suggested you could put in as many arrays as you wanted, so you'd have to pass the other stuff with explicit keywords.

JetsGuy
Sep 17, 2003

science + hockey
=
LASER SKATES

aeverous posted:

Man some of you guys are so good at reading other peoples code that's just mathematically impenetrable to me, I guess that comes with years of experience. As a self taught programmer though I think I might be hitting a bit of a wall, I have trouble designing efficient algorithms in particular, you good programmers seem to use some mathematical knowledge to make something efficient where I would make a huge set of nested loops. Might not be the thread for it but I realised this while reading this page, can someone recommend a book that contains the maths necessary to be a good programmer but is accessible? Like not necessarily a college student's maths textbook, but more in depth than high school level maths?

For me its part experience, part reading this thread, and stack overflow for years.

Thinking back, it amazes me how much better I've become (and how much more I have to go). Like I said, looking at the code I wrote when i first was learning, I am shocked at how I coded that then and how I would code it now. Like you, I have no formal training in python (or any other code), I've just had one scientific programming class, but most of the coding I do now I am self taught in.

PS - Stack Overflow is great, but can be kind of frustrating at times.

QuarkJets
Sep 8, 2008

I don't really understand how to spot whether I may be writing spaghetti or ravioli code. I want to be a good python programmer, so I have read the most recent PEP and I try to code readable but efficient code. Would anyone mind posting examples of python spaghetti/ravioli code for examples of how not to code? With no formal training but years of experience, I am worried about bad habits that I may not even realize I have

Adbot
ADBOT LOVES YOU

Thermopyle
Jul 1, 2003

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

QuarkJets posted:

I don't really understand how to spot whether I may be writing spaghetti or ravioli code. I want to be a good python programmer, so I have read the most recent PEP and I try to code readable but efficient code. Would anyone mind posting examples of python spaghetti/ravioli code for examples of how not to code? With no formal training but years of experience, I am worried about bad habits that I may not even realize I have

For one thing, follow the Coding Horrors thread.

  • Locked thread