|
dantheman650 posted:Thanks for this! I like the Udacity layout better than Coursera and I enjoy the ability to study at my own pace. The first lesson is making a poker program, which, coincidentally, is one of the last exercises in Think Python, so that seems like a good sign this will be appropriate for my level. I'll give it a go.
|
# ? Feb 17, 2015 03:12 |
|
|
# ? May 9, 2024 12:58 |
|
Hey guys, just a short question thanks Any has anyone here worked with Django and made Open ERP or Odoo modules? The Django thread seems super technical so I rather post here. How hard is it working with 3rd party API's for "basic" functionality? Signed up for coursera "An Introduction to Interactive Programming in Python (Part 1)" course. Hopefully I can stick to the end and get something out of it. dantheman650 posted:I was actually just coming to this thread to say thank you to the posters several months ago who recommended this book. I slowly worked my way through it in my free time and finished it today. The exercises were supremely helpful and well-designed and I feel like I understand Python basics extremely well. Hey coursera buddy. I'm still super beginner and have a basic grasp of objects and javascript. If you ever want someone slightly behind your level or work something let's do it. Maybe we can do django together and work on github.
|
# ? Feb 17, 2015 05:39 |
|
Hey time for more Bokeh! Here's a little video of a new example, there's more on the blog announcement. https://www.youtube.com/watch?v=F0jXmtvmpHY Big news is R language bindings, for anyone that might also use R.
|
# ? Feb 17, 2015 18:18 |
|
I did conda update --all on my iMac and it's been doing thisquote:Fetching package metadata: .. Could take a while indeed.
|
# ? Feb 17, 2015 20:00 |
|
Hey guys, I'm relearning python, and doing it via code academy. I'm trying to be dumb and do things a step above, and I suppose make it.. different? Dunno, trying things, but I can't remember if I can do a for loop like this:code:
also, is there a way to call which step you are in on a for loop?
|
# ? Feb 18, 2015 16:20 |
|
Gothmog1065 posted:Hey guys, I'm relearning python, and doing it via code academy. I'm trying to be dumb and do things a step above, and I suppose make it.. different? Dunno, trying things, but I can't remember if I can do a for loop like this: Do you mean this? Python code:
code:
Space Kablooey fucked around with this message at 17:10 on Feb 18, 2015 |
# ? Feb 18, 2015 16:31 |
|
Gothmog1065 posted:Hey guys, I'm relearning python, and doing it via code academy. I'm trying to be dumb and do things a step above, and I suppose make it.. different? Dunno, trying things, but I can't remember if I can do a for loop like this: You never want to set your variable names programmatically. If you're tempted to do so, a dictionary might be what you're looking for. So it would be weighted_score[item] = foo which would "come out as" weighted_score['homework'] = foo.
|
# ? Feb 18, 2015 16:57 |
|
HardDisk posted:Do you mean this? Thanks! I ended up with: code:
SurgicalOntologist posted:You never want to set your variable names programmatically. If you're tempted to do so, a dictionary might be what you're looking for. So it would be weighted_score[item] = foo which would "come out as" weighted_score['homework'] = foo. Duly noted.
|
# ? Feb 18, 2015 17:09 |
|
Putting it all together:Python code:
|
# ? Feb 18, 2015 18:54 |
|
Can anyone recommend some reading/reference material for learning Flask?
|
# ? Feb 19, 2015 02:24 |
|
I started with the mega-tutorial. I'm also working with it for almost two years now, if you hit a snag I can probably help you.
|
# ? Feb 19, 2015 03:30 |
|
I'm guessing this is more of a Python question than a SQL question, so here goes: For an assignment (on Udacity - create a Swiss-style tournament database), I need to create a function that will return a list of tuples, each of which contains (id, name, wins, matches) from a PostgreSQL database. No problem there, but I'm getting tuples like: (420, 'Dick Butt', None, None) I'm only supposed to insert the player's name (ID is generated by SQL) when I create a new player - inserting "0"s for their wins and matches is cheating. The function that tests my function wants "0"s in the wins and matches: code:
caberham posted:Signed up for coursera "An Introduction to Interactive Programming in Python (Part 1)" course. I'm in this course too . Check out my CEE-LO dice game in the Hall of Fame discussion board!
|
# ? Feb 19, 2015 06:11 |
|
PongAtari posted:I'm guessing this is more of a Python question than a SQL question, so here goes: The most graceful way to do this is in the database layer, by setting default values of 0 for both your wins and matches columns. Then your queries could return zeros without technically breaking "insert only the players name" rule.
|
# ? Feb 19, 2015 06:38 |
|
supercrooky posted:The most graceful way to do this is in the database layer, by setting default values of 0 for both your wins and matches columns. Then your queries could return zeros without technically breaking "insert only the players name" rule. Thanks, I'll give that a shot.
|
# ? Feb 19, 2015 06:43 |
|
PongAtari posted:I'm guessing this is more of a Python question than a SQL question, so here goes: Oh wow, that's you! That's awesome. I'm going to make something next weekend. Maybe we should have our goon newbies group or something and make projects of goatse
|
# ? Feb 19, 2015 07:03 |
|
PongAtari posted:I'm guessing this is more of a Python question than a SQL question, so here goes: Alternatively, if you're forced to work with a database design that is dumb, you could do something like this in your SQL query: code:
|
# ? Feb 19, 2015 09:12 |
|
I am currently in the process of learning Python for data analysis. I am using wakari (https://www.wakari.io), and am currently working through a bunch of basic data transformation tasks to get my head around things. My background is SAS and SQL so I am finding data transformation in Python to be EXTREMELY difficult and frustrating. I am sure that once I get the hang of things I will wiz through this stuff however for whatever reason my dumb brain cannot figure out basic concatenation to derive new columns. If I had a dataframe with the following columns, model, productID, productname, sales 2010, 1101, widget, 43 2010, 1102, gidget, 12 How do I create a new column in the dataframe that a. Combines model and productID into a new column b. Combines productname and sales into a new column (I realise these are dumb examples but they capture the casting, new columns, and concatenation problems they are having) model, productID, productname, sales, newcolA, newcolB 2010, 1101, widget, 43, 20101101, widget43 2010, 1102, gidget, 12, 20101102, gidget12 I am using Panda for other data transformation tasks but as a COMPLETE python newbie I am stumped. I've worked through different examples which use series or variables, that involve casting int to string using different methods but I can't seem to bring it all together and make it happen inside a dataframe. I keep just wanting to rush back to SAS but I know that if I stick with it I won't look back. Help!
|
# ? Feb 19, 2015 20:01 |
|
I'm trying to decide how to get a complex blob from one python script to another. I have a few different scripts. One's a polling loop waiting for instructions from a remote computer, one's a graphics driver that can take some time to update the screen. The loop calls the driver with subprocess.open() to avoid blocking. The driver currently takes args as one complete command, e.g. "./driver.py Text 15 50 'Hello!' " puts the string Hello! at x=15,y=50. I want to send more than one update to the driver at a time and I'm not sure how to package them up. I'd love to just have a list of lists, keep the current internal structure and loop over it multiple times. But I'm not sure how to send a list of lists in the command line arguments. I'm considering a flat file that keeps each current command on its own line. It's stupid and slow, but I can afford slow and I'm not going to get any smarter. Is there some easier way or is the file system the easiest way to smuggle this data around? e: smuggling throuhg filesystem worked, back to the terrible implementation at hand JawnV6 fucked around with this message at 01:23 on Feb 20, 2015 |
# ? Feb 19, 2015 21:25 |
|
sc0tty posted:I am currently in the process of learning Python for data analysis. I am using wakari (https://www.wakari.io), and am currently working through a bunch of basic data transformation tasks to get my head around things. If those columns are strings, you can just add them. If not, you need to make them strings, then add them (in Python addition for strings is concatenation; in pandas it will automatically apply the addition operation to the whole column). Python code:
SurgicalOntologist fucked around with this message at 21:42 on Feb 19, 2015 |
# ? Feb 19, 2015 21:40 |
|
JawnV6 posted:I'm trying to decide how to get a complex blob from one python script to another. I'm not quite picturing what you're doing, but could you just send JSON as a command line argument in your subprocess call?
|
# ? Feb 20, 2015 02:09 |
|
Master_Odin posted:The proper way would be as supercrooky pointed out would be to set a default on the field to 0 such that it auto defaults to 0 on insertion when only inserting player name. This can also be code:
|
# ? Feb 20, 2015 06:03 |
|
nm
Liam Emsa fucked around with this message at 06:16 on Feb 20, 2015 |
# ? Feb 20, 2015 06:12 |
|
Ah, see you caught it but just a few tips of style: don't explicitly compare booleans to True or False -- while leaver == True: should just be while leaver:; you can simplify those numerical comparisons like f >= 0.25 and f < 0.50: to 0.25 <= f < 0.5; and that chain of those exclusive conditions should be of the form if... elif... else rather than if... if... if....
|
# ? Feb 20, 2015 06:24 |
|
I have an assignment for a job I'm trying to get that requires I parse 20 books' titles, authors, weight, etc. from some saved files, pack boxes based on the weight, and spit out the box arrangements in JSON format. The README specifically says "submissions with only a single class are not worthy", so I've got classes for Books, Boxes, and the Shipment. I'm having trouble figuring out a good way to get each object's __repr__ working properly so I can print the Shipment at the end. Is there any sage wisdom on accomplishing this? The code is currently roughly like this:Python code:
|
# ? Feb 20, 2015 09:36 |
|
Try looking into what jsonpickle does.
|
# ? Feb 20, 2015 16:17 |
What do I do with my requirements.txt and setup.py if I want to support both Python 2 and 3, with different dependencies depending on what version you're using. i.e. I need unicodecsv for Python 2, but not for Python 3. edit: Nevermind I think I found a good example of how to do this: https://github.com/aws/aws-cli
|
|
# ? Feb 20, 2015 22:42 |
|
Is there a reliable way in python to search for a string directly in a pdf? I have script that loses a lot of time because it is having to convert a 60 page pdf to text file, then search for its information.
|
# ? Feb 21, 2015 00:05 |
|
Hughmoris posted:Is there a reliable way in python to search for a string directly in a pdf? I have script that loses a lot of time because it is having to convert a 60 page pdf to text file, then search for its information. Are these PDF files that have already been OCR'ed or have text information?
|
# ? Feb 21, 2015 00:42 |
|
accipter posted:Are these PDF files that have already been OCR'ed or have text information? To be honest, I'm not sure I know the answer. How could I check? Using pdf2txt, it converts everything I need to a text file just fine. I don't know if that means I can assume the PDF files have text information. I tried using pdfminer before to search directly in pdf but I got all turned around, had a whole bunch of objects I didn't know how to manipulate.
|
# ? Feb 21, 2015 00:52 |
|
Thermopyle posted:I'm not quite picturing what you're doing, but could you just send JSON as a command line argument in your subprocess call? That would've worked, yes. I was sweating a demo that happened a couple hours ago, turns out they hadn't seen it do the wireless bits yet so I really shouldn't have been worried at all. I might move to JSON, depending on how much more this has to grow. There's enough issues with the relevant display technology that I might not have time to drill down into it. Hughmoris posted:Is there a reliable way in python to search for a string directly in a pdf? I have script that loses a lot of time because it is having to convert a 60 page pdf to text file, then search for its information.
|
# ? Feb 21, 2015 00:59 |
|
JawnV6 posted:That would've worked, yes. I was sweating a demo that happened a couple hours ago, turns out they hadn't seen it do the wireless bits yet so I really shouldn't have been worried at all. I think I'll figure out how to post my code on github, maybe someone might see a glaring problem that is slowing things down.
|
# ? Feb 21, 2015 01:02 |
|
If you're using pdf2txt from here, it mentions: quote:PDFMiner is about 20 times slower than other C/C++-based counterparts such as XPdf. If you're doing: 1. Take user input 2. Convert Global.pdf to Global.txt with pdf2txt 3. Search user input in Global.txt You could replace step 2 with a faster tool with relative ease. e: or just use Pastebin?
|
# ? Feb 21, 2015 01:06 |
|
JawnV6 posted:If you're using pdf2txt from here, it mentions: Ok, I uploaded my code. The purpose of the script is to find and extract a single page of a PDF, from a folder full of multi-page PDF files. I had to rename/remove one or two things for privacy purposes, but I think its all simple enough to get the gist. http://pastebin.com/ftXEfRGD This code may make you run for the hills, its about a week's worth of google searching python functions and reverse engineering things to meet my needs. Forgive me for my sins. Hughmoris fucked around with this message at 01:59 on Feb 21, 2015 |
# ? Feb 21, 2015 01:57 |
|
I haven't got into the meat of it but why are you using subprocess.call to run a Python script as opposed to just importing that module and calling a function?
|
# ? Feb 21, 2015 02:08 |
|
KICK BAMA KICK posted:I haven't got into the meat of it but why are you using subprocess.call to run a Python script as opposed to just importing that module and calling a function? Learning as I go along and following examples I find online. I'll try to do that with pdf2txt, and I guess I'll have to use subprocess with Adobe Reader still?
|
# ? Feb 21, 2015 02:10 |
Why is --no-site-packages not working? I can't figure out how six 1.8.0 is making it into my virtualenv, I didn't think I even had to specify --no-site-packages since it should be the default behavior, it doesn't seem to work either way though.code:
|
|
# ? Feb 21, 2015 02:25 |
|
If I have a list of lists such as the following:code:
code:
code:
Also I am loading the list of lists in from a tab separated file if that helps. Should I be setting this up by first making a list of objects instead? cowofwar fucked around with this message at 04:45 on Feb 21, 2015 |
# ? Feb 21, 2015 04:40 |
|
cowofwar posted:If I have a list of lists such as the following: Check out collections.namedtuple in the standard library
|
# ? Feb 21, 2015 04:51 |
|
motorcyclesarejets posted:Check out collections.namedtuple in the standard library
|
# ? Feb 21, 2015 05:46 |
|
|
# ? May 9, 2024 12:58 |
|
I'm beating my head against the wall about a seemingly simple problem. This is a simple test block for code that will eventually delete a wild card from a poker hand, then create a list of all possible hands (each represented by a list of cards) by substituting each possible card in for the wild card and adding that hand to the list. This is the homework for the Udacity course recommended on the previous page. (I'm loving the course and also CheckIO - thanks for recommending them!)code:
If I add some print statements to debug, one after each of the statements in the for loop, I get this: code:
|
# ? Feb 21, 2015 08:30 |