Two Plus Two Poker Forums

Two Plus Two Poker Forums (https://forumserver.twoplustwo.com/)
-   Computer and Technical Help (https://forumserver.twoplustwo.com/48/computer-technical-help/)
-   -   ** Python Support Thread ** (https://forumserver.twoplustwo.com/48/computer-technical-help/python-support-thread-1007515/)

Xhad 07-23-2012 05:09 PM

Re: ** Python Support Thread **
 
Code:

a
This is a variable named "a".

Code:

"a"
This is a string comprising the letter "a".

Colombo 07-23-2012 05:25 PM

Re: ** Python Support Thread **
 
I am going to try to write a GUI program for my fantasy football leagues' live drafts this year.

My first though was to write it in javascript and run it on localhost, but I've never worked with python GUI stuff so I'd like to learn it.

Anyone have any experience/recommendations for which GUI package to use? It seems like there are many options - with TkInter being the stdlib one.

The program should be fairly simple and not very intensive. I'll simply have a form which holds all of the players and various information about them, a "DRAFT ME" button, and a second page/tab which lists the big board (where and to which team each player was drafted).

Mariogs37 07-23-2012 07:05 PM

Re: ** Python Support Thread **
 
OK, so you'd only do that when comparing strings. When comparing integers, you wouldn't use quotes...yeah?

myNameIsInga 07-23-2012 07:16 PM

Re: ** Python Support Thread **
 
Quote:

Originally Posted by Mariogs37 (Post 33909133)
OK, so you'd only do that when comparing strings. When comparing integers, you wouldn't use quotes...yeah?

Yes. with no quotes you are comparing something to a variable. that is you are comparing something to the content in the variable. With the quotes you are not comparing to a variable but rather to a string. If you want to compare something with a particular integer you could simply type the integer (like 45), although that might not be good coding practice

Xhad 07-23-2012 07:21 PM

Re: ** Python Support Thread **
 
Code:

a = 5
b = "a"

a == 5 #True
"a" == 5 #False
a == "5" #False
b == 5 #False
b == a #False
b == "a" #True


Mariogs37 07-23-2012 08:02 PM

Re: ** Python Support Thread **
 
Thanks guys. Fwiw, an actual explanation is much more helpful than the above.

daveT 07-23-2012 08:14 PM

Re: ** Python Support Thread **
 
What Xhad did was wholly appropriate: Python has a REPL that you should learn to use and master. He simply showed you the steps you may want to take when you use it.

Comparisons like this are something you have to teach yourself in order to understand it and your not going to learn w/o experimentation. You're facing a midterm, this is day-one stuff.

myNameIsInga 07-23-2012 08:20 PM

Re: ** Python Support Thread **
 
Quote:

Originally Posted by Mariogs37 (Post 33910038)
Thanks guys. Fwiw, an actual explanation is much more helpful than the above.

What is it you want to see explained?

Neko 07-23-2012 08:52 PM

Re: ** Python Support Thread **
 
Quote:

Originally Posted by Colombo (Post 33907437)
I am going to try to write a GUI program for my fantasy football leagues' live drafts this year.

My first though was to write it in javascript and run it on localhost, but I've never worked with python GUI stuff so I'd like to learn it.

Anyone have any experience/recommendations for which GUI package to use? It seems like there are many options - with TkInter being the stdlib one.

The program should be fairly simple and not very intensive. I'll simply have a form which holds all of the players and various information about them, a "DRAFT ME" button, and a second page/tab which lists the big board (where and to which team each player was drafted).

The two big players are wxPython and QT (Pyside). I've used wx extensively over the last 4 years and have been pretty happy with it. It's cross-platform, the guis look nice and it's pretty easy to pick up. It's also easy to create distributable executables using py2exe/py2app or pyinstaller. This guys blog http://www.blog.pythonlibrary.org/tag/wxpython/ has lots of good tutorials on it.

QT is maybe a bit more popular and includes more "application framework" stuff than wx. I don't have much experience with it though so I can't really comment on it.

You might also want to check out http://www.python-camelot.com/ which is built on top of QT. I saw a talk by the creator at a Python conference and it looked pretty cool.

Mariogs37 07-23-2012 10:23 PM

Re: ** Python Support Thread **
 
@myNameisInga,

Meant that your explanation was more helpful than Xhad's. No offense meant to either, just an observation.

fluffheadsr 07-23-2012 10:28 PM

Re: ** Python Support Thread **
 
Quote:

Originally Posted by jjshabado (Post 25804134)
It's funny - I was of the same opinion. Except I recently started working more on a pylons app and its light years ahead of any java stack I've ever used in terms of overall ease of development.

I'm still not sold on building large applications in it - but it's growing on me.

EVE Online... the largest game in the world.. probably the largest single application of code? It's pretty fing big, runs on python..

i think it handles large applications alright.

tyler_cracker 07-23-2012 10:30 PM

Re: ** Python Support Thread **
 
Quote:

Originally Posted by Mariogs37 (Post 33910038)
Thanks guys. Fwiw, an actual explanation is much more helpful than the above.

lol. *plonk*

jjshabado 07-23-2012 10:44 PM

Re: ** Python Support Thread **
 
Quote:

Originally Posted by fluffheadsr (Post 33912480)
EVE Online... the largest game in the world.. probably the largest single application of code? It's pretty fing big, runs on python..

i think it handles large applications alright.

First, cite? Largest single application of code seems like a pretty bold claim.

Second, one application being written in a language isn't proof of anything. If you want to debate the merits of python vs. whatever - I'm cool with that, but this is a silly post. So to counter your one vague data point with one of my own. Friends of mine at Google say that python is discouraged for large applications. It's used for scripting, prototypes, and small projects but thats about it.

Neko 07-23-2012 11:12 PM

Re: ** Python Support Thread **
 
yeah, there is no way EVE is the largest application in the world. My guess is teh largest program in the world is written in COBOL :p

myNameIsInga 07-24-2012 05:59 AM

Re: ** Python Support Thread **
 
Quote:

Originally Posted by Mariogs37 (Post 33912380)
@myNameisInga,

Meant that your explanation was more helpful than Xhad's. No offense meant to either, just an observation.

didn't take offense, sorry it seemed that way. I just wondered if there was something you wanted an explanation to, given you are studying for an exam

Mariogs37 07-24-2012 12:43 PM

Re: ** Python Support Thread **
 
Quote:

Originally Posted by daveT (Post 33910251)
What Xhad did was wholly appropriate: Python has a REPL that you should learn to use and master. He simply showed you the steps you may want to take when you use it.

Comparisons like this are something you have to teach yourself in order to understand it and your not going to learn w/o experimentation. You're facing a midterm, this is day-one stuff.

There's a difference between giving the answer and explaining it. Inga's response explained it, Xhad's was relatively terse and didn't offer much of an explanation.

Also, it's not a matter of Xhad's post being appropriate. It's a matter of responses being helpful. And, given that this is a support thread, it's *probably* better if the responses are helpful...

Finally, your comment about "this is day-one stuff." What does the that have to do with anything?

I could have posted something like "lol DaveT, learn calc 1 before posting in this thread." But it'd be irrelevant.

kerowo 07-24-2012 12:54 PM

Re: ** Python Support Thread **
 
These are user supported forums, meaning no one here is getting paid to answer questions. Complaining about the tone of a forum is all well and good, but getting mad at people for not answering the question the way you want is not going to go over well on 2+2. The comment about you line of questioning being fist day stuff should have indicated to you to go back to whatever text book or notes you are taking for this corse and see where the hole in your learning was.

clowntable 07-24-2012 03:40 PM

Re: ** Python Support Thread **
 
Quote:

Originally Posted by Mariogs37 (Post 33910038)
Thanks guys. Fwiw, an actual explanation is much more helpful than the above.

Code:

if letter in ['a','e','i','o','u']: print('ZOMG')
Migh clear up the code a bit :)
(replace print with counting or whatever you want to do of course)

Mariogs37 07-24-2012 03:49 PM

Re: ** Python Support Thread **
 
@Kerowo,

I'm well aware these are user-supported forums; I help out in the SMP Math/Physics HW thread all the time. Who's getting mad here? I was providing constructive criticism. It's not as if someone responding can either:

a) give advice that's terse/uninstructive or
b) not give advice at all

There's actually a third option: namely, giving advice and providing some sort of motivation for it, even if it *seems* obvious.

The comment that "you're facing a mid-term, this is day-one stuff" is just a ****head thing to say. Let's not pretend it was actually meant to help me figure out exactly where in the book to find the answer.

My assumption in saying that more explanation is more helpful was meant to be constructive; my guess is most people prefer more explanation rather than just the answer.

kerowo 07-24-2012 04:06 PM

Re: ** Python Support Thread **
 
You're reading tone into a post that probably isn't there. To my ear the tone of your constructive criticism was worse than the day one stuff response.

Mariogs37 07-24-2012 04:34 PM

Re: ** Python Support Thread **
 
As much as I want to debate this, let's move on.

daveT 07-25-2012 03:38 AM

Re: ** Python Support Thread **
 
Mariogs, if you'd like a correlation, imagine if someone went into SMP and said they had a mid-term tomorrow, and they came in with this question:

"What's the difference between y and y(0)?"

And knowing that the mid-term likely covers stuff the chain rule and implicit differentiation or MVT, I guess you'd be pretty much falling out of your seat if someone came in and asked such a question. Did they do any homework at all? Did they think about anything they wrote down as they wrote it? Did they skip the entire first half the class and are now cramming?

Understanding the difference between a string, a number, and a variable is so fundamental to programming that I can tell you just about what page it is in any introductory text on programming or "Learn XXXX Language" book: less than 5 pages after the Introduction and About Us" page.

This book dives into the nitty-gritty on page 11, which is the first page of Chapter 2, one page after the introduction: http://www.greenteapress.com/thinkpython/thinkCSpy.pdf

This book starts the same thing on page 37, which yeah, has a long-winded 2-chapter introduction on the virtues of Python:

http://books.google.com/books?id=1Hx...python&f=false

But them again, programmers can't live without google: http://www.google.com/webhp?rlz=1C1L...w=1366&bih=667

Google is a wonderful resource and repository for basic programming questions. You'll find 1,000 word blogs on your question.

WeAreSamurai 07-25-2012 02:01 PM

Re: ** Python Support Thread **
 
I trying to get into programming graphics. I've looked around a bit and it looks like tkinter, pygtk, pyqt, and wxpython are the main modules being used. I'm curious what the big differences are between these, if any. Generally the posts I've seen will say that which one is the best will depend on what you're trying to do, but I haven't seen anything that says if you're trying to do x, this is better, if you're trying to do y, that one's is better.

Am I right thinking that tkinter is good to start learning, but I should move on to one of the others when I can? It seems some people seem to think tkinter isn't robust enough. And then from there it's pretty much all similar. What are other people using?

clowntable 07-25-2012 03:09 PM

Re: ** Python Support Thread **
 
I'm kind of in the same boat but would actually prefer xulrunner or something like that. Alas I don't really have much time to compare etc.

I also seem to be incapable of googling something usefull for "web technology based multi window application development" or basically "what are my options if I want to develop a multi window desktop application but kind of want it to run everywhere and use webby stuff"

HolidayInTheSun 07-26-2012 12:53 AM

Re: ** Python Support Thread **
 
i am still very much a python beginner. i've gone through a python book and understand the simple examples. now i'm trying to use python to scrape data. this is difficult thus far.

i'm using beautiful soup and urllib2. i've looked at several examples which have helped me to write lines of code that is getting me closer to what i want to do. but i still haven't gotten to the point of being able to actually put that data into a meaningful format that can be analysed, much less scrape it in a systematic patterned way so that the process could be automatized to pull hundreds of data points.

here's an extremely simple example from stackoverflow, and i can't even replicate it, and i have no idea why:

http://stackoverflow.com/questions/2...ng-with-python

in the link, someone poses a question about how to scrape sunrise and sunset times. another user posts an answer (the first one) which ought to do the trick. however, when i copy paste this code, i do not see a list of sunrise/sunset times.

either: i copy paste the entire code

Code:

import urllib2
from bs4 import BeautifulSoup

soup = BeautifulSoup(urllib2.urlopen('http://www.timeanddate.com/worldclock/astronomy.html?n=78').read())

for row in soup('table', {'class' : 'spad'})[0].tbody('tr'):
  tds = row('td')
  print tds[0].string, tds[1].string
  # will print date and sunrise

when i do the above, python just goes back to showing >>>. i don't get an error message, but there's no evidence that anything actually happened. i would expect it to print out some sunrise times.

or, i will copy paste this part:

Code:

import urllib2
from bs4 import BeautifulSoup

soup = BeautifulSoup(urllib2.urlopen('http://www.timeanddate.com/worldclock/astronomy.html?n=78').read())

and then in a second step copy paste

Code:

for row in soup('table', {'class' : 'spad'})[0].tbody('tr'):
  tds = row('td')
  print tds[0].string, tds[1].string
  # will print date and sunrise

and when i do this i get
Code:

Traceback (most recent call last):
  File "<pyshell#90>", line 3, in <module>
    print tds[0].string, tds[1].string
  File "C:\Python27\lib\idlelib\rpc.py", line 595, in __call__
    value = self.sockio.remotecall(self.oid, self.name, args, kwargs)
  File "C:\Python27\lib\idlelib\rpc.py", line 210, in remotecall
    seq = self.asynccall(oid, methodname, args, kwargs)
  File "C:\Python27\lib\idlelib\rpc.py", line 225, in asynccall
    self.putmessage((seq, request))
  File "C:\Python27\lib\idlelib\rpc.py", line 324, in putmessage
    s = pickle.dumps(message)
  File "C:\Python27\lib\copy_reg.py", line 74, in _reduce_ex
    getstate = self.__getstate__
RuntimeError: maximum recursion depth exceeded

i'm concerned because if i can't even replicate this simple example, i must be doing a ton of stuff wrong.

why do i get an error message when i copy/paste in 2 waves instead of typing it all in one wave? shouldn't it not matter, as the first paste is just identifying the variable soup, which should still be stored when i paste the second half? why am i getting maximum recursion error? why is it not printing the sunrises and sunsets in the first example where i copy/paste the entire thing and nothing happens?

thanks for your help!


All times are GMT -4. The time now is 06:18 PM.

Powered by vBulletin®
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.

Copyright © 2008-2020, Two Plus Two Interactive