Re: smtplib not working as expected

2014-12-27 Thread Juan Christian
On Sat Dec 27 2014 at 1:23:12 AM Vincent Vande Vyvre 
vincent.vande.vy...@telenet.be wrote:
Try with the TLS:

Many thanks, working like a charm, code:

server = smtplib.SMTP('smtp.mail.ru')
server.starttls()
server.ehlo()
server.login('SENDER EMAIL GOES HERE', 'PASSWD GOES HERE')
server.sendmail(fromaddr, toaddrs, msg)
server.quit()
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: smtplib not working as expected

2014-12-27 Thread Juan Christian
Denis it was already resolved, check my message above. ^^
-- 
https://mail.python.org/mailman/listinfo/python-list


smtplib not working as expected

2014-12-26 Thread Juan Christian
I have the following test code:

import smtplib

fromaddr = 'mksfjnsfji4433j4...@bk.ru'
toaddrs  = ['mksfjnsfji4433j4...@bk.ru']

msg = (From: %s\r\nTo: %s\r\n\r\n
   % (fromaddr, , .join(toaddrs)))

msg = msg + 'test'

print(Message length is  + repr(len(msg)))

server = smtplib.SMTP('smtp.mail.ru', 465)
server.set_debuglevel(1)
server.sendmail(fromaddr, toaddrs, msg)
server.quit()

And when I execute it, it keeps running forever and I don't get any email.
What's missing, what's wrong? The smtp server and port are correct -
https://help.mail.ru/enmail-help/mailer/popsmtp

I'm following this tutorial:https://docs.python.org/3/library/smtplib.html

Python 3.4.2
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: smtplib not working as expected

2014-12-26 Thread Juan Christian
On Fri Dec 26 2014 at 11:07:30 PM MRAB pyt...@mrabarnett.plus.com wrote:
According to the docs, if you let the port parameter default to 0,
it'll use port 465.

I tested with my ISP.

Using port 465, it failed.

Using the default, it succeeded.

So, I changed the code how you said, but still not working.


Code:

import smtplib

fromaddr = 'mksfjnsfji4433j4...@bk.ru'
toaddrs = ['mksfjnsfji4433j4...@bk.ru']

msg = (From: %s\r\nTo: %s\r\n\r\n
% (fromaddr, , .join(toaddrs)))

msg = msg + 'test'

server = smtplib.SMTP('smtp.mail.ru')
server.set_debuglevel(1)
server.sendmail(fromaddr, toaddrs, msg)
server.quit()


Traceback:

send: 'ehlo [192.168.0.107]\r\n'
reply: b'250-smtp15.mail.ru\r\n'
reply: b'250-SIZE 73400320\r\n'
reply: b'250-8BITMIME\r\n'
reply: b'250-PIPELINING\r\n'
reply: b'250-AUTH PLAIN LOGIN XOAUTH2\r\n'
reply: b'250 STARTTLS\r\n'
reply: retcode (250); Msg: b'smtp15.mail.ru\nSIZE
73400320\n8BITMIME\nPIPELINING\nAUTH PLAIN LOGIN XOAUTH2\nSTARTTLS'
send: 'mail FROM:mksfjnsfji4433j4...@bk.ru size=70\r\n'
reply: b'250 2.0.0 OK\r\n'
reply: retcode (250); Msg: b'2.0.0 OK'
send: 'rcpt TO:mksfjnsfji4433j4...@bk.ru\r\n'
reply: b'550 SMTP is available only with SSL or TLS connection enabled.\r\n'
reply: retcode (550); Msg: b'SMTP is available only with SSL or TLS
connection enabled.'
send: 'rset\r\n'
Traceback (most recent call last):
File .\test.py, line 13, in module
server.sendmail(fromaddr, toaddrs, msg)
File C:\Python34\lib\smtplib.py, line 793, in sendmail
raise SMTPRecipientsRefused(senderrs)
smtplib.SMTPRecipientsRefused: {'mksfjnsfji4433j4...@bk.ru': (550, b'SMTP
is available only with SSL or TLS connection e
nabled.')}
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Is there a way to schedule my script?

2014-12-18 Thread Juan Christian
On Wed Dec 17 2014 at 11:04:16 PM Juan Christian juan0christ...@gmail.com
wrote:
Thanks. That was a great answer. I'll redo my code. It's running and will
only run in my Docker container (Ubuntu Server 14.04.1) so I'll use cron.

Indeed, currently I'm using something like that:

while True:
if 9  datetime.now().hour  24:
# do stuff
sleep(randint(3, 6) * 60)
else:
# see you in 9 hours
sleep(9 * 60 * 60)

I knew it wasn't a good approach, but as least it was running as intended!


I read the cron doc, it's really simple to use, but one think I didn't see
out-of-the-box is a way to set a random time, like 'execute this in a 5~10
min interval', I can only set specific times like 'execute this each
minute, each hour, each 10min' and so on.

I found a 'fix' for that using $RANDOM in the crontab. Another workaround
would be to set a fixed 5min interval in cron and inside my script have a
random int (0 or 1), when 0, the script doesn't execute and 1 it execute,
so that way I'd have a little 'randomness' that I need.

Which approach would be the best?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Is there a way to schedule my script?

2014-12-18 Thread Juan Christian
Thanks, using cron here.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Is there a way to schedule my script?

2014-12-18 Thread Juan Christian
On Thu Dec 18 2014 at 2:24:46 PM Ian Kelly ian.g.ke...@gmail.com wrote:
What kind of random distribution of the time between executions are you
looking for? A random sleep lends itself easily to a uniform distribution.
The latter approach that you describe would result in a geometric
distribution.

I'm looking for a random, but controlled delay between executions.

Let's say I execute the script now, then in 5~10 min I'll execute again,
this time can be 5, 6, ... 10 minutes, this script pretends to do 'human
actions' so I can't be doing these 'actions' with a specific and rigid
times.

The delay between the executions can't be the same always.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Is there a way to schedule my script?

2014-12-18 Thread Juan Christian
On Thu Dec 18 2014 at 11:35:11 PM Chris Angelico ros...@gmail.com wrote:
Why does this matter to you? Why am I getting the feeling that I
should not be helping you?

Because that's what my project is all about, I need to fake some 'human
actions' inside the network to do some benchmarks and test internal stuffs.
This need to be 'flexible'.
-- 
https://mail.python.org/mailman/listinfo/python-list


Is there a way to schedule my script?

2014-12-17 Thread Juan Christian
I know about the schedule modules and such but they work in situations like
'run this in a X hours/minutes/seconds interval', I already have my code in
a while loop with sleep (it's a bit ugly, I'l change to a scheduler soon).

What I really want is, for example:

24/7/365
9:00 AM - Start
11:59 PM - Stop

9:00 AM ~ 11:50 PM - Running
12:00 AM ~ 8:59 AM - Stopped

I want my script to start at a given time and stop at another given time,
is that possible?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Is there a way to schedule my script?

2014-12-17 Thread Juan Christian
On Wed Dec 17 2014 at 5:45:31 PM John Gordon gor...@panix.com wrote:
You could write a separate program whose only job is to send a STOP or
CONTINUE signal to your main program, and then run that program from a
scheduler.

The standard system kill command would probably work for this purpose,
assuming you have access to your main program's process ID.

There isn't any 'prettier' way? Such as a built-in or third-party module
for something common like that?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Is there a way to schedule my script?

2014-12-17 Thread Juan Christian
Ops, sorry.

It's: 9:00 AM ~ 11:59 PM - Running

... and not 9:00 AM ~ 11:50 PM - Running
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Is there a way to schedule my script?

2014-12-17 Thread Juan Christian
On Wed Dec 17 2014 at 6:25:39 PM John Gordon gor...@panix.com wrote:
If you want to solve your problem entirely within Python, look at the
scheduler module. (Although even this isn't a complete solution, as you
still have to make sure the program is running in the first place...)


My script is running fine, Win/OSX/Linux and I don't want to ruin that
using system specific things.

I looked at sched doc and it's only for creating a delay, maybe a good
approach would be to call the sched and check if time = 11:59PM, then set
delay to 1h and when the time goes 9AM, it returns to my normal delay.

Is there any kind of time calculation in Python that counts the time like
0, 1, 2, 3... so that 0AM would be 0, and 11:59PM would be let's say
'64562'? And everyday it gets a reset when the clock 'turns'?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Is there a way to schedule my script?

2014-12-17 Thread Juan Christian
On Wed Dec 17 2014 at 7:35:10 PM Chris Angelico ros...@gmail.com wrote:

time.time() % 86400

That's number of seconds since midnight UTC, ranging from 0 up to
86399. (I've no idea what 64562 would mean. That's an awfully big
number for a single day.) If you offset that before calculating, you
can get that in your local time. Otherwise, just do the arithmetic
directly. Time isn't all _that_ hard to work with.

I don't see what's the big problem with just using sleep() though.
Isn't that exactly what you're after?

This was a random number I invented So, I'm already using sleep to make
my script execute some funcs in a defined interval, but when the time is
0AM-9AM I don't want the delay to be the normal one (randint(5,10) * 60) -
5~10min, I want it to be like 2hours.

The script will be running 24/7, but from 0AM to 9AM it will slowdown a
bit.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Is there a way to schedule my script?

2014-12-17 Thread Juan Christian
On Wed Dec 17 2014 at 9:40:52 PM Steven D'Aprano 
steve+comp.lang.pyt...@pearwood.info wrote:

 Juan Christian wrote:

  I know about the schedule modules and such but they work in situations
  like 'run this in a X hours/minutes/seconds interval', I already have my
  code in a while loop with sleep (it's a bit ugly, I'l change to a
  scheduler soon).
 [...]
  I want my script to start at a given time and stop at another given time,
  is that possible?

 The right solution to this is probably to use your operating system's
 scheduler to run your script at whatever time or times you want. Under
 Unix/Linux, that is cron. I'm sure Windows will have it's own, but I don't
 know what it is.

 Then your script then doesn't have to care about times at all, it just runs
 and does its thing, and the OS controls when it runs. cron is amazingly
 flexible.

 This is the proper separation of concerns. Your script doesn't have to deal
 with memory management, or the file system, or scheduling times, that is
 the operating system's job. The OS already has tools to do this, and can do
 them *much better than you*. (What happens if your script dies? What about
 when the time changes, say because of daylight savings?)

 Unless you are running on some primitive OS with no way to control when
 jobs
 run except to manually run them, the *wrong* solution is a busy-wait loop:

 while True:
 # Wait forever, doing nothing.
 sleep(0.1)  # Yawn.
 if now() == some_time():
 do_this()


 It doesn't matter if you use the sched module to shift the time check to
 another part of your code if the main loop does nothing. The critical
 question here is this:

 While you are waiting for the scheduled time, does your main loop
 continuously do any other work?

 If the answer is Yes, then using sched is the right approach.

 If the answer is No, then your main loop is just killing time, doing
 nothing
 but sleeping and waiting, like somebody checking their wristwatch every two
 seconds. You should simplify your script by getting rid of the main loop
 completely and let your OS handle the timing:

 # No loop at all.
 do_this()


Thanks. That was a great answer. I'll redo my code. It's running and will
only run in my Docker container (Ubuntu Server 14.04.1) so I'll use cron.

Indeed, currently I'm using something like that:

while True:
if 9  datetime.now().hour  24:
# do stuff
sleep(randint(3, 6) * 60)
else:
# see you in 9 hours
sleep(9 * 60 * 60)

I knew it wasn't a good approach, but as least it was running as intended!
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Fwd: Python Signal/Slot + QThred code analysis

2014-11-28 Thread Juan Christian
On Fri Nov 28 2014 at 2:07:32 AM Michael Torrie torr...@gmail.com wrote:
Okay, here's a reworking of the code that invokes a new QThread instance
each time. Note the QThread instance has to be bound to the MainWindow
so that it won't be destroyed when it goes out of scope. Also the
Worker thread sends a signal with the data, so there's no need to check
worker.trades and risk it being invalid data.

Perhaps this would be more what you had in mind.

You may want to look into asynchronous I/O as well. That does not
require threads at all. Fire off a request to load a url, and then get
a callback when it's done.


Now it's working like a charm without any freezes. I'll reproduce this
'Worker' for other stuffs that I need to call the web, but first I have a
question.

Which one would be better in performance, having a single 'Worker' to call
all URLs, having inside this worker functions for each stuff, or having 3~5
different workers doing different stuff. In the end I'll only print the
data when I have them all.

The problem is that I would have a long new_value = Signal(QThread, str,
str), with more then 10 values, is it possible to pass objects here
like new_value = Signal(QThread, ObjA, ObjB, ...) so that in the
'create_topic' I would get the objects and call methods in order to get all
the data?

This approach would be better, because I may be adding more stuff and I
wouldn't need to add tons and tons of new stuff in my signal, only one
object.

You don't need to redo the code, I just need to know if it's a 'good
approach' and if it's possible, from here I can work my way.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Fwd: Python Signal/Slot + QThred code analysis

2014-11-27 Thread Juan Christian
On Thu Nov 27 2014 at 2:12:40 AM Michael Torrie torr...@gmail.com wrote:
Hmm, I hit a wall. There's no main.ui file. Can you rework your code
so that you have a single file (plus a separate ui file that's okay),
that simulates the url request, that I can execute easily.

As you asked, here it's, everything on one module and without network
calls, http://pastebin.com/ibS9FSSd

The main.ui is a XML, http://pastebin.com/Eq9hNMBX , just save it as
main.ui and it will work. I think now you have everything in order to test
the app.

What I have in mind is simple (I think), have the Outpost get the data
using QThread, and when it got everything needed emit a signal. So when I
have something like 'var = Outpost('123')', when I get the signal I'll know
that I can call 'var.trades, var.posts' and it won't give me NullErrors or
something like that.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Fwd: Python Signal/Slot + QThred code analysis

2014-11-27 Thread Juan Christian
On Thu Nov 27 2014 at 8:53:16 PM Michael Torrie torr...@gmail.com wrote:
Hope this helps. Here's complete working code, minus the .ui file:
http://pastebin.com/VhmSFX2t

Thanks, I'll just repost the code on pastebin with a NEVER expire time and
UNLISTED, so that it can be of some help for others here in the mailist:
http://pastebin.com/9Jrmw4VL

I'll read the code thoroughly and reply to you if I find something strange,
many thanks!
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Fwd: Python Signal/Slot + QThred code analysis

2014-11-27 Thread Juan Christian
On Thu Nov 27 2014 at 9:16:38 PM Juan Christian juan0christ...@gmail.com
wrote:
I'll read the code thoroughly and reply to you if I find something strange,
many thanks!


So, instantly I found one issue, you said that this code won't block the
GUI, only the thread event loop, but if we keep moving the window while
it's open, every time new info is printed the GUI freezes for like 1-2
seconds.

And why this approach of a single instance is better? I mean, I'll have to
call Outpost every time I get new data from my other API, because there
will be different users, so I need to create different instances so I call
the site with a new ID, don't I?

Maybe the answer for that question is that you using a timer that is ALWAYS
active and ALWAYS calling the the outpost site, so I'll have something like:

var = Outpost('12345')
var.posts - 100
var.setID('67893')
var.posts - 35

Is that right? But I don't think that always calling the site this way is
good for them and for me, sometimes I may not get new users for like 10~15
minutes, so I would have wasted a lot of calls for nothing. That's why I
only instantiate/call the site when I get new users.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Fwd: Python Signal/Slot + QThred code analysis

2014-11-26 Thread Juan Christian
On Wed Nov 26 2014 at 1:16:11 AM Michael Torrie torr...@gmail.com wrote:
You're going to have to post a complete, but small, code example, I
think. Working with fragments of code is very difficult if not
impossible to assist with, resulting in obtuse, obvious replies from folks.

As asked, here is all the code:

outpost module: http://pastebin.com/H3K9UUWi
main module: http://pastebin.com/dFzums9W

I was trying to do other things there but I ended up screwing everything.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python Signal/Slot + QThred code analysis

2014-11-25 Thread Juan Christian
On Mon Nov 24 2014 at 11:56:31 PM Michael Torrie torr...@gmail.com wrote:
Looks alright. Does it work?

Well, no =/

First I had to remove the multiple inheritance, because Qt doesn't allow
that, so I removed the QObject.

Second, just for testing I'm calling the module directly using:

timer = QTimer()
timer.start(5000)

def output_slot():
outpost = Outpost('123456')
outpost.start()
MainWindow.vlay.addWidget(create_box(outpost.info_a +  :  +
outpost.info_b))

timer.timeout.connect(output_slot)

But I'm getting this:

Traceback (most recent call last):
  File D:\Documents\PyCharm\Trader\Trader\core\outpost.py, line 18, in run
with soup.select('div.stat_box div.value')[0].get_text().replace(',',
'') as trades, \
AttributeError: __exit__
-- 
https://mail.python.org/mailman/listinfo/python-list


Fwd: Python Signal/Slot + QThred code analysis

2014-11-25 Thread Juan Christian
On Tue Nov 25 2014 at 1:42:24 PM MRAB pyt...@mrabarnett.plus.com wrote:
I think that the problem there is that strings don't have an __exit__
method.

I don't understand what you said, what you mean by that? =/
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Fwd: Python Signal/Slot + QThred code analysis

2014-11-25 Thread Juan Christian
So guys, I had to change to approach, I read that using Qt I can't do
multiple inheritance. So my Outpost class can't be like 'Outpost(QObject,
QThred)'. I had to change the code a bit:

from PySide.QtCore import QObject, QThread, Signal
import requests
import bs4


class Worker(QThread):
def __init__(self, url, *args, **kwargs):
super().__init__(*args, **kwargs)
self.trades = None
self.posts = None
self.url = url
self.start()

def run(self):
soup = bs4.BeautifulSoup(requests.get(self.url).text)
self.trades = soup.select('div.stat_box
div.value')[0].get_text().replace(',', '')
self.posts = soup.select('div.stat_box div.value')[1].get_text()
return self


class Outpost(QObject):
received = Signal()

def __init__(self, id64, *args, **kwargs):
super().__init__(*args, **kwargs)
worker = Worker('http://www.myurl.com/' + id64)
self.received.emit(worker)

So, what I see people doing is creating a 'Worker' class for thread related
stuff and another separate class for the main stuff.

So, let's see the problems:

Traceback (most recent call last):
  File D:/.../main.py, line 44, in output_slot
outpost = Outpost('12345')
  File D:\...\outpost.py, line 27, in __init__
self.received.emit(worker)
TypeError: received() only accepts 0 arguments, 2 given!

The URL is OK, I externally checked, and return the expected.

So, what I'm trying to do here is call my Worker when outpost is
instantiated, then the Worker call the site in the run function, and then
set the variables and return itself.

Back to the main class, I have the init where I instantiate the Worker and
return it in the emit().

If I got it correctly, when I call the 'outpost.received.connect(IPSUM)',
IPSUM will be execute when, and only when I have all values set, because in
my Outpost class it will emit when it has everything done, did I get it
right?

OFF-TOPIC: You guys said that my emails had some trash HTML and strange
stuffs, is it OK now?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python Signal/Slot + QThred code analysis

2014-11-24 Thread Juan Christian
Oh, and this code I made by myself, I didn't copy. That's why I want you
guys to see if everything is ok.
-- 
https://mail.python.org/mailman/listinfo/python-list


Python Signal/Slot + QThred code analysis

2014-11-23 Thread Juan Christian
This is a continuation of my other topic How to access Qt components
loaded from file, it was getting big and the focus changed completely, the
real question there was already answered, and we were talking about
signal/slot, QThred and other things.

So, I read on the web (didn't find books talking about QThred, Signal/Slot)
and I came up with this code:

Python 3.4.2
PySide 1.2.2

from PySide.QtCore import QObject, QThread, Signal
import requests
import bs4

class Outpost(QObject, QThread):
received = Signal()

def __init__(self, uid, *args, **kwargs):
super().__init__(*args, **kwargs)
self.url = 'http://www.myurl.com/user/' + uid

def run(self):
soup = bs4.BeautifulSoup(requests.get(self.url).text)

with soup.select('div.stat_box div.value')[0].get_text().replace(',',
'') as a, soup.select('div.stat_box div.value')[1].get_text() as b:
self.info_a = a
self.info_b = b

self.received.emit(self)

Is this code good?

I'll explain what I think this code does, when I was doing this: First I
created my custom signal, 'received'. Then I made my __init__ just to set a
uid.

Then, the run func, I read that's the one that will run when working with
threads. Here I set the soup and I get the page content using requests,
that's the part that will take more time.

Then I use bs4 to set my data, and yes, I know that getting data this way
isn't the best option, but I don't have other choice, they don't give APIs
for this stuff.

Later I emit my signal when I have everything set and I pass the entire
class with it so I can call the 'var.info_a' and 'bar.info_b' wherever I
want.

Did I think correctly, can I do anything better here? Many thanks.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How to access Qt components loaded from file?

2014-11-21 Thread Juan Christian
On Fri Nov 21 2014 at 8:05:30 AM alister alister.nospam.w...@ntlworld.com
wrote:

 All of this VVV
 [...]


I'm sorry, I didn't know, but it seems there isn't any option to remove
that in the Inbox (new Gmail), do you guys use any special program or
client to use list?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How to access Qt components loaded from file?

2014-11-20 Thread Juan Christian
So, I need to study QThreads, do you know any book or video-course that
talks about this matter? I've seen the tutorials that you pointed but I
need a wider approach regarding QThreads to really understand it and
apply it to my needs. The docs aren't that clear for me.

On Thu Nov 20 2014 at 1:43:21 PM Michael Torrie torr...@gmail.com wrote:

 On 11/19/2014 07:53 PM, Juan Christian wrote:
  Thanks, it's working using QTimer. The thing is that whenever the program
  is going to do something, in my case, draw a new QGroupBox with some
  components inside and put it in the Form (I'm using VBoxLayout in the
 main
  form) the program freezes, and I'm using very simple components just for
  testing.This shouldn't be normal, right?
 
  Am I doing something wrong?

 I clicked send too soon. The stackoverflow link is really referring to
 another link, which is much more complete and hopefully helpful to you:

 http://joplaete.wordpress.com/2010/07/21/threading-with-pyqt4/


 --
 https://mail.python.org/mailman/listinfo/python-list

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How to access Qt components loaded from file?

2014-11-20 Thread Juan Christian
Yes, I read everything and saw that stackoverlfow on Google too. I'm
reading this doc: http://pyqt.sourceforge.net/Docs/PyQt4/classes.html

I just asked for a book because normally there are books for anything =p

On Thu Nov 20 2014 at 5:08:09 PM Michael Torrie torr...@gmail.com wrote:

 On 11/20/2014 10:57 AM, Juan Christian wrote:
  So, I need to study QThreads, do you know any book or video-course that
  talks about this matter? I've seen the tutorials that you pointed but I
  need a wider approach regarding QThreads to really understand it and
  apply it to my needs. The docs aren't that clear for me.

 Yes you should definitely study up on QThreads.  What is unclear about
 the docs?  Which docs did you read? Did you read the links I sent you,
 particularly the wordpress blog post where he had a complete example
 (although I understand that it's not quite the correct way to do it)?
 What things have you tried searching for?

 Google reveals another discussion on stackoverflow which seems to give
 you a pretty complete, and correct, example:
 http://stackoverflow.com/questions/16241297/how-to-
 signal-from-a-running-qthread-back-to-the-pyqt-gui-that-started-it
 .  Note that the first post there is not working, but the fix is listed
 in the second post.  Put them together and you'll have a working example.
 --
 https://mail.python.org/mailman/listinfo/python-list

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How to access Qt components loaded from file?

2014-11-20 Thread Juan Christian
Another problem is that this doc doesn't use Python.

On Thu Nov 20 2014 at 5:36:37 PM Juan Christian juan0christ...@gmail.com
wrote:

 Yes, I read everything and saw that stackoverlfow on Google too. I'm
 reading this doc: http://pyqt.sourceforge.net/Docs/PyQt4/classes.html

 I just asked for a book because normally there are books for anything =p

 On Thu Nov 20 2014 at 5:08:09 PM Michael Torrie torr...@gmail.com wrote:

 On 11/20/2014 10:57 AM, Juan Christian wrote:
  So, I need to study QThreads, do you know any book or video-course that
  talks about this matter? I've seen the tutorials that you pointed but I
  need a wider approach regarding QThreads to really understand it and
  apply it to my needs. The docs aren't that clear for me.

 Yes you should definitely study up on QThreads.  What is unclear about
 the docs?  Which docs did you read? Did you read the links I sent you,
 particularly the wordpress blog post where he had a complete example
 (although I understand that it's not quite the correct way to do it)?
 What things have you tried searching for?

 Google reveals another discussion on stackoverflow which seems to give
 you a pretty complete, and correct, example:
 http://stackoverflow.com/questions/16241297/how-to-signal-
 from-a-running-qthread-back-to-the-pyqt-gui-that-started-it
 .  Note that the first post there is not working, but the fix is listed
 in the second post.  Put them together and you'll have a working example.
 --
 https://mail.python.org/mailman/listinfo/python-list


-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How to access Qt components loaded from file?

2014-11-20 Thread Juan Christian
**Back to the list

So, as I said the PyQt doc is using C o.0

Yes, I read the tutorials, I'll google for some books and things related.

On Tue Nov 18 2014 at 10:48:44 AM Vincent Vande Vyvre 
vincent.vande.vy...@telenet.be wrote:

 Le 18/11/2014 13:18, Juan Christian a écrit :
  I have this simple code that load any Qt Designer .UI file:
 
  from PySide.QtCore import QFile
  from PySide.QtGui import QApplication
  from PySide.QtUiTools import QUiLoader
 
 
  def loadui(file_name):
  loader = QUiLoader()
  uifile = QFile(file_name)
  uifile.open(QFile.ReadOnly)
  ui = loader.load(uifile)
  uifile.close()
  return ui
 
 
  if __name__ == __main__:
  import sys
 
  app = QApplication(sys.argv)
  MainWindow = loadui(main.ui)
  MainWindow.show()
  app.exec_()
 
  Let's say I have a QTextEdit called txtbox. How can I access this
  txtbox inside my Python code?
 
 
 How about MainWindow.txtbox  ?
 --
 https://mail.python.org/mailman/listinfo/python-list

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How to access Qt components loaded from file?

2014-11-20 Thread Juan Christian
On Thu Nov 20 2014 at 7:07:10 PM Mark Lawrence breamore...@yahoo.co.uk
wrote:

 You also need to study the difference between top posting, interspersed
 posting and bottom posting.  The second and third are very much the
 prefered styles here.


Yes I know, but I'm using the new Google Inbox, and I limited to what I can
do when replying, to do the right way I have to do many steps now...
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How to access Qt components loaded from file?

2014-11-20 Thread Juan Christian
On Thu Nov 20 2014 at 8:20:29 PM alister alister.nospam.w...@ntlworld.com
wrote:

 Then either do the necessary work (you have just proven you can)or find a
 better way of communicating with this news group(NNTP or the mailing
 list), otherwise you may find a number of good people simply ignore your
 posts.

 While you are at it try to restrict your replies to text only, i see a
 lot of html garbage at the end of your posts which is also off putting.


Which HTML garbage you talking about?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How to access Qt components loaded from file?

2014-11-19 Thread Juan Christian
Let's say that I want to call the site in a 5min interval. I'm currently
getting the info this way just for testing and to know that the 'core
engine' is working, and indeed, it's working:

if __name__ == __main__:
import sys

app = QApplication(sys.argv)
MainWindow = loadui(main.ui)

def output_slot():
MainWindow.txtbox.setText(call_site())

MainWindow.btn.clicked.connect(output_slot)

MainWindow.show()
app.exec_()

How can I proceed if I want the txtbox to automatically do the
'setText(call_site())' in a X defined interval? The final app will have not
only a txtbox, but a complete interface with buttons, avatar image, some
txtboxes, and all that stuff. If I know how to call the site in a defined
interval, I can get all the info that I need and set them one by one.

If I'm not mistaken my app is locked in the app.exec_() loop, so I need to
have a trigger configured that will be called in a defined interval, then
inside this trigger I configure the set_avatar, set_text,
set_btn_link, etc, is that right?

On Tue Nov 18 2014 at 9:37:21 PM Chris Angelico ros...@gmail.com wrote:

 On Wed, Nov 19, 2014 at 5:15 AM, Juan Christian
 juan0christ...@gmail.com wrote:
 
  Thanks, it's working. What would be a professional approach if I want
 to
  constantly call a URL to get it's content and access this data within the
  GUI?
 

 Constantly doesn't make much sense when you're talking about network
 operations. There are two basic approaches: either you re-fetch
 periodically and update the GUI (in which case you have to decide how
 frequently), or you re-fetch on some trigger (when it's changed, or
 when the user's about to need it, or something). Either way, you have
 to balance network traffic versus promptness of update, and it's
 nearly impossible to pick perfectly. But if you don't mind it being a
 little clunky, you should be able to pick something fairly simple and
 deploy it, and then maybe refine it a bit afterward.

 ChrisA
 --
 https://mail.python.org/mailman/listinfo/python-list

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How to access Qt components loaded from file?

2014-11-19 Thread Juan Christian
Thanks, it's working using QTimer. The thing is that whenever the program
is going to do something, in my case, draw a new QGroupBox with some
components inside and put it in the Form (I'm using VBoxLayout in the main
form) the program freezes, and I'm using very simple components just for
testing.This shouldn't be normal, right?

Am I doing something wrong?

On Wed Nov 19 2014 at 7:00:43 PM Rob Gaddi
rgaddi@technologyhighland.invalid wrote:

 On Wed, 19 Nov 2014 20:47:31 +
 Juan Christian juan0christ...@gmail.com wrote:

  Let's say that I want to call the site in a 5min interval. I'm currently
  getting the info this way just for testing and to know that the 'core
  engine' is working, and indeed, it's working:
 
  if __name__ == __main__:
  import sys
 
  app = QApplication(sys.argv)
  MainWindow = loadui(main.ui)
 
  def output_slot():
  MainWindow.txtbox.setText(call_site())
 
  MainWindow.btn.clicked.connect(output_slot)
 
  MainWindow.show()
  app.exec_()
 
  How can I proceed if I want the txtbox to automatically do the
  'setText(call_site())' in a X defined interval? The final app will have
 not
  only a txtbox, but a complete interface with buttons, avatar image, some
  txtboxes, and all that stuff. If I know how to call the site in a
 defined
  interval, I can get all the info that I need and set them one by one.
 
  If I'm not mistaken my app is locked in the app.exec_() loop, so I need
 to
  have a trigger configured that will be called in a defined interval, then
  inside this trigger I configure the set_avatar, set_text,
  set_btn_link, etc, is that right?
 
  On Tue Nov 18 2014 at 9:37:21 PM Chris Angelico ros...@gmail.com
 wrote:
 
   On Wed, Nov 19, 2014 at 5:15 AM, Juan Christian
   juan0christ...@gmail.com wrote:
   
Thanks, it's working. What would be a professional approach if I
 want
   to
constantly call a URL to get it's content and access this data
 within the
GUI?
   
  
   Constantly doesn't make much sense when you're talking about network
   operations. There are two basic approaches: either you re-fetch
   periodically and update the GUI (in which case you have to decide how
   frequently), or you re-fetch on some trigger (when it's changed, or
   when the user's about to need it, or something). Either way, you have
   to balance network traffic versus promptness of update, and it's
   nearly impossible to pick perfectly. But if you don't mind it being a
   little clunky, you should be able to pick something fairly simple and
   deploy it, and then maybe refine it a bit afterward.
  
   ChrisA
   --
   https://mail.python.org/mailman/listinfo/python-list
  
 
 You'd use a QTimer to do that.  Once you .start(5*60*1000) the
 timer, it'll fire a timeout signal every 5 minutes.  You connect that
 timeout to the slots you want to execute if you don't care about order,
 or to a single slot function that runs the things that you want to do in
 some defined order.

 --
 Rob Gaddi, Highland Technology -- www.highlandtechnology.com
 Email address domain is currently out of order.  See above to fix.
 --
 https://mail.python.org/mailman/listinfo/python-list

-- 
https://mail.python.org/mailman/listinfo/python-list


How to access Qt components loaded from file?

2014-11-18 Thread Juan Christian
I have this simple code that load any Qt Designer .UI file:

from PySide.QtCore import QFile
from PySide.QtGui import QApplication
from PySide.QtUiTools import QUiLoader


def loadui(file_name):
loader = QUiLoader()
uifile = QFile(file_name)
uifile.open(QFile.ReadOnly)
ui = loader.load(uifile)
uifile.close()
return ui


if __name__ == __main__:
import sys

app = QApplication(sys.argv)
MainWindow = loadui(main.ui)
MainWindow.show()
app.exec_()

Let's say I have a QTextEdit called txtbox. How can I access this txtbox
inside my Python code?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How to access Qt components loaded from file?

2014-11-18 Thread Juan Christian
Many thanks, worked. The only problem now is that I don't have
auto-complete for anything, because of this approach... I'll have to check
the doc more regularly. ^^

On Tue Nov 18 2014 at 10:48:44 AM Vincent Vande Vyvre 
vincent.vande.vy...@telenet.be wrote:

 Le 18/11/2014 13:18, Juan Christian a écrit :
  I have this simple code that load any Qt Designer .UI file:
 
  from PySide.QtCore import QFile
  from PySide.QtGui import QApplication
  from PySide.QtUiTools import QUiLoader
 
 
  def loadui(file_name):
  loader = QUiLoader()
  uifile = QFile(file_name)
  uifile.open(QFile.ReadOnly)
  ui = loader.load(uifile)
  uifile.close()
  return ui
 
 
  if __name__ == __main__:
  import sys
 
  app = QApplication(sys.argv)
  MainWindow = loadui(main.ui)
  MainWindow.show()
  app.exec_()
 
  Let's say I have a QTextEdit called txtbox. How can I access this
  txtbox inside my Python code?
 
 
 How about MainWindow.txtbox  ?
 --
 https://mail.python.org/mailman/listinfo/python-list

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How to access Qt components loaded from file?

2014-11-18 Thread Juan Christian
I was doing some tests, then I tried this:

app = QApplication(sys.argv)
MainWindow = loadui(main.ui)
MainWindow.btn.clicked.connect(MainWindow.txtbox.setText(test()))

MainWindow.show()
app.exec_()

But I get RuntimeError: Failed to connect signal clicked()., why?

The syntax is correct, I don't know why it failed, the btn is in the Form
too, it's a QPushButton.

The test func is just a simple func that returns a random text.

On Tue Nov 18 2014 at 11:08:48 AM Juan Christian juan0christ...@gmail.com
wrote:

 Many thanks, worked. The only problem now is that I don't have
 auto-complete for anything, because of this approach... I'll have to check
 the doc more regularly. ^^

 On Tue Nov 18 2014 at 10:48:44 AM Vincent Vande Vyvre 
 vincent.vande.vy...@telenet.be wrote:

 Le 18/11/2014 13:18, Juan Christian a écrit :
  I have this simple code that load any Qt Designer .UI file:
 
  from PySide.QtCore import QFile
  from PySide.QtGui import QApplication
  from PySide.QtUiTools import QUiLoader
 
 
  def loadui(file_name):
  loader = QUiLoader()
  uifile = QFile(file_name)
  uifile.open(QFile.ReadOnly)
  ui = loader.load(uifile)
  uifile.close()
  return ui
 
 
  if __name__ == __main__:
  import sys
 
  app = QApplication(sys.argv)
  MainWindow = loadui(main.ui)
  MainWindow.show()
  app.exec_()
 
  Let's say I have a QTextEdit called txtbox. How can I access this
  txtbox inside my Python code?
 
 
 How about MainWindow.txtbox  ?
 --
 https://mail.python.org/mailman/listinfo/python-list


-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How to access Qt components loaded from file?

2014-11-18 Thread Juan Christian

 You can't have a slot like this:

 MainWindow.btn.clicked.connect(MainWindow.txtbox.setText(test()))

 because that's mean: connect to the return of
 MainWindow.txtbox.setText(test()) and it's not possible at this stage
 of your program.

 Use instead a function:

 MainWindow.btn.clicked.connect(my_slot) # No parenthesis !

 def my_slot():
  MainWindow.txtbox.setText(test())


Thanks, it's working. What would be a professional approach if I want to
constantly call a URL to get it's content and access this data within the
GUI?

I mean, when I run the program I'm locked in the app.exec_() continuous
loop right? So I can't have a loop to get this data from the web, is there
any special signal/slot regarding this?
-- 
https://mail.python.org/mailman/listinfo/python-list


PySide 1.2.2 setMaxWidth and AeroSnap

2014-11-16 Thread Juan Christian
PySide 1.2.2
Python 3.4.2

Code:

from PySide.QtGui import *

class MainWindow(QWidget):
def __init__(self):
QWidget.__init__(self)
self.setMinimumSize(600, 700)
self.setMaximumWidth(600)
self.setLayout(QVBoxLayout())

* Call to this module in another module *
app = QApplication(sys.argv)
window = MainWindow()
window.show()
app.exec_()

When I set the setMaxWidth I can't use the Windows AeroSnap anymore, why?

I didn't set a setMaxHeight, so this shouldn't lock me from doing the
snap. Without the setMaxWidth the AeroSnap works as usual, but I need to
limit my width to 600, because I need my tool to have this kind of
short-width, long-height look.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: PySide 1.2.2 setMaxWidth and AeroSnap

2014-11-16 Thread Juan Christian
On Sun Nov 16 2014 at 3:46:40 PM Vincent Vande Vyvre 
vincent.vande.vy...@telenet.be wrote:

 No probleme with PyQt but I think this is a window manager question.
 Window, gnome, KDE, Mate, ...


 If your widget is a QMainWindow or a QDialog add a size grip:

  self.setSizeGripEnabled(True)

 The QWidget don't have this method, so, in this case, you must
 reimplement his resizeEvent()


I changed to QMainWindow, but I don't have a function called
setSizeGripEnabled here.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python 3.4.2 + PyQt4 + PyCharm 3.4.1

2014-11-06 Thread Juan Christian
Resolved, kinda. Just use PySide instead of PyQt.

Remove everything PyQt related from PyCharm and install PySide using the
PyCharm plugins window.

PySide has access to all modules and packages that PyQt has, but now you
need to import like from PySide.** import *.
On Thu, Nov 6, 2014 at 12:50 farshad akbari akbari.fars...@gmail.com
wrote:

 On Saturday, November 1, 2014 3:11:54 PM UTC+3:30, Juan Christian wrote:
  No one here uses PyCharm and Qt? =/
 
 
  On Wed, Oct 29, 2014 at 8:45 PM, Juan Christian juan0ch...@gmail.com
 wrote:
 
  It only occurs whule using PyCharm I tried it via pure terminal and
 everything works... =/
 
 
 
 
  On Tue, Oct 28, 2014 at 7:45 PM, Juan Christian juan0ch...@gmail.com
 wrote:
 
 
  Python 3.4.2 Windows x64
  PyQt4 4.11.2 Py3.4 Qt4.8.6 (x64)
 
  PyCharm 3.4.1 Pro Edition
 
 
 
 
  So, PyCharm works 100% with everything here but PyQt.
 
 
  I have this folder structure:
 
 
  Disk C:
   PyQt4
   Lib/site-packages/PyQt4/(tons of files here)
 
 
   Python34 (normal/default installation)
 
 
  ---
 
 
  I tried copying the 'PyQt4' folder to my 'Python34/Lib/site-packages'
 folder but when I try to code something Qt related on PyCharm I get this
 issue:
 
 
 
  Some skeletons failed to generate: 19 modules failed in 1 interpreter.
 Details...
 
 
 
  Failed modules
 
 
  Python 3.4.2
  PyQt4.QAxContainer
  PyQt4.Qsci
  PyQt4.QtCore
  PyQt4.QtDeclarative
  PyQt4.QtDesigner
  PyQt4.QtGui
  PyQt4.QtHelp
  PyQt4.QtMultimedia
  PyQt4.QtNetwork
  PyQt4.QtOpenGL
  PyQt4.QtScript
  PyQt4.QtScriptTools
  PyQt4.QtSql
  PyQt4.QtSvg
  PyQt4.QtTest
  PyQt4.QtWebKit
  PyQt4.QtXml
  PyQt4.QtXmlPatterns
  PyQt4.phonon
 
 
  Generation of skeletons for the modules above will be tried again when
 the modules are updated or a new version of generator is available.
 
 
  And PyCharm tells me that my 'import PyQt4.ANYTHING_HERE import *' has
 'Unresolved references'.
 
 
  ---
 
 
  When I try to install the PyQt4 via the installer, in the default
 location (C:/Python34) I get an even 'worse' error, whenever PyCharm try to
 update the skeletons or something like that (that is, whenever I open a
 file there...), I get tons and tons of the same error, 'Error while
 accessing memory at address ', and 'python.exe' stops working.

 i have this problem too,
 and it's so annoying.
 --
 https://mail.python.org/mailman/listinfo/python-list

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python 3.4.2 + PyQt4 + PyCharm 3.4.1

2014-11-01 Thread Juan Christian
No one here uses PyCharm and Qt? =/

On Wed, Oct 29, 2014 at 8:45 PM, Juan Christian juan0christ...@gmail.com
wrote:

 It only occurs whule using PyCharm I tried it via pure terminal and
 everything works... =/

 On Tue, Oct 28, 2014 at 7:45 PM, Juan Christian juan0christ...@gmail.com
 wrote:

 Python 3.4.2 Windows x64
 PyQt4 4.11.2 Py3.4 Qt4.8.6 (x64)
 PyCharm 3.4.1 Pro Edition


 So, PyCharm works 100% with everything here but PyQt.

 I have this folder structure:

 Disk C:
  PyQt4
  Lib/site-packages/PyQt4/(tons of files here)

  Python34 (normal/default installation)

 ---

 I tried copying the 'PyQt4' folder to my 'Python34/Lib/site-packages'
 folder but when I try to code something Qt related on PyCharm I get this
 issue:

 Some skeletons failed to generate: 19 modules failed in 1 interpreter.
 Details...

 Failed modules

 Python 3.4.2
 PyQt4.QAxContainer
 PyQt4.Qsci
 PyQt4.QtCore
 PyQt4.QtDeclarative
 PyQt4.QtDesigner
 PyQt4.QtGui
 PyQt4.QtHelp
 PyQt4.QtMultimedia
 PyQt4.QtNetwork
 PyQt4.QtOpenGL
 PyQt4.QtScript
 PyQt4.QtScriptTools
 PyQt4.QtSql
 PyQt4.QtSvg
 PyQt4.QtTest
 PyQt4.QtWebKit
 PyQt4.QtXml
 PyQt4.QtXmlPatterns
 PyQt4.phonon

 Generation of skeletons for the modules above will be tried again when
 the modules are updated or a new version of generator is available.

 And PyCharm tells me that my 'import PyQt4.ANYTHING_HERE import *' has
 'Unresolved references'.

 ---

 When I try to install the PyQt4 via the installer, in the default
 location (C:/Python34) I get an even 'worse' error, whenever PyCharm try to
 update the skeletons or something like that (that is, whenever I open a
 file there...), I get tons and tons of the same error, 'Error while
 accessing memory at address ', and 'python.exe' stops working.



-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python 3.4.2 + PyQt4 + PyCharm 3.4.1

2014-10-29 Thread Juan Christian
It only occurs whule using PyCharm I tried it via pure terminal and
everything works... =/

On Tue, Oct 28, 2014 at 7:45 PM, Juan Christian juan0christ...@gmail.com
wrote:

 Python 3.4.2 Windows x64
 PyQt4 4.11.2 Py3.4 Qt4.8.6 (x64)
 PyCharm 3.4.1 Pro Edition


 So, PyCharm works 100% with everything here but PyQt.

 I have this folder structure:

 Disk C:
  PyQt4
  Lib/site-packages/PyQt4/(tons of files here)

  Python34 (normal/default installation)

 ---

 I tried copying the 'PyQt4' folder to my 'Python34/Lib/site-packages'
 folder but when I try to code something Qt related on PyCharm I get this
 issue:

 Some skeletons failed to generate: 19 modules failed in 1 interpreter.
 Details...

 Failed modules

 Python 3.4.2
 PyQt4.QAxContainer
 PyQt4.Qsci
 PyQt4.QtCore
 PyQt4.QtDeclarative
 PyQt4.QtDesigner
 PyQt4.QtGui
 PyQt4.QtHelp
 PyQt4.QtMultimedia
 PyQt4.QtNetwork
 PyQt4.QtOpenGL
 PyQt4.QtScript
 PyQt4.QtScriptTools
 PyQt4.QtSql
 PyQt4.QtSvg
 PyQt4.QtTest
 PyQt4.QtWebKit
 PyQt4.QtXml
 PyQt4.QtXmlPatterns
 PyQt4.phonon

 Generation of skeletons for the modules above will be tried again when the
 modules are updated or a new version of generator is available.

 And PyCharm tells me that my 'import PyQt4.ANYTHING_HERE import *' has
 'Unresolved references'.

 ---

 When I try to install the PyQt4 via the installer, in the default location
 (C:/Python34) I get an even 'worse' error, whenever PyCharm try to update
 the skeletons or something like that (that is, whenever I open a file
 there...), I get tons and tons of the same error, 'Error while accessing
 memory at address ', and 'python.exe' stops working.


-- 
https://mail.python.org/mailman/listinfo/python-list


Python 3.4.2 + PyQt4 + PyCharm 3.4.1

2014-10-28 Thread Juan Christian
Python 3.4.2 Windows x64
PyQt4 4.11.2 Py3.4 Qt4.8.6 (x64)
PyCharm 3.4.1 Pro Edition


So, PyCharm works 100% with everything here but PyQt.

I have this folder structure:

Disk C:
 PyQt4
 Lib/site-packages/PyQt4/(tons of files here)

 Python34 (normal/default installation)

---

I tried copying the 'PyQt4' folder to my 'Python34/Lib/site-packages'
folder but when I try to code something Qt related on PyCharm I get this
issue:

Some skeletons failed to generate: 19 modules failed in 1 interpreter.
Details...

Failed modules

Python 3.4.2
PyQt4.QAxContainer
PyQt4.Qsci
PyQt4.QtCore
PyQt4.QtDeclarative
PyQt4.QtDesigner
PyQt4.QtGui
PyQt4.QtHelp
PyQt4.QtMultimedia
PyQt4.QtNetwork
PyQt4.QtOpenGL
PyQt4.QtScript
PyQt4.QtScriptTools
PyQt4.QtSql
PyQt4.QtSvg
PyQt4.QtTest
PyQt4.QtWebKit
PyQt4.QtXml
PyQt4.QtXmlPatterns
PyQt4.phonon

Generation of skeletons for the modules above will be tried again when the
modules are updated or a new version of generator is available.

And PyCharm tells me that my 'import PyQt4.ANYTHING_HERE import *' has
'Unresolved references'.

---

When I try to install the PyQt4 via the installer, in the default location
(C:/Python34) I get an even 'worse' error, whenever PyCharm try to update
the skeletons or something like that (that is, whenever I open a file
there...), I get tons and tons of the same error, 'Error while accessing
memory at address ', and 'python.exe' stops working.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python 3.4.1 and blitzdb issue

2014-10-22 Thread Juan Christian
Oh yes, and here is what the call to the API returns:

{adult:false,also_known_as:[George Walton Lucas Jr.
],biography:Arguably the most important film innovator in the history
of the medium, George Lucas continually \pushed the envelope\ of
filmmaking technology since his early days as a student at U.S.C.
Considered a wunderkind by his contemporaries, he had a much harder time
communicating his vision to studio executives, whose meddling managed to
compromise each of his first three feature directing efforts in some way.
The monumental success of \Star Wars\ (1977) ushered in the era of the
\summer blockbuster,\ which, despite the later popularity of low budget
independent films, was still the prevailing mentality powering the
Hollywood engine.\n\nThough he set the tone and established the
expectations which influenced studios to devote the bulk of their resources
to films designed to blast off into hyperspace for spectacular profits, it
was doubtful that a film as revolutionary as \Star Wars\ was in its day
could get made in the later blockbuster assembly line climate of the new
millennium.,birthday:1944-05-14,deathday:,homepage:,id:1,imdb_id:nm184,name:George
Lucas,place_of_birth:Modesto - California -
USA,popularity:2.185575,profile_path:/rJ1zvSeZfge0mHtLnzJn4Mkw18S.jpg}

On Wed, Oct 22, 2014 at 2:34 PM, Juan Christian juan0christ...@gmail.com
wrote:

 Testing code:

 CODE -

 #!/usr/bin/env

 import requests
 from blitzdb import Document, FileBackend


 API_URL = 'http://api.themoviedb.org/3'
 API_KEY = 'ddf30289'


 class Actor(Document):
 pass


 def get_actor(_id):
 r = requests.get('{}/person/{}?api_key={}'.format(API_URL, str(_id),
 API_KEY))
 return r.json()


 actor_1 = Actor(get_actor(1))
 actor_2 = Actor(get_actor(2))

 backend = FileBackend(db.blitz)
 actor_1.save(backend)
 actor_2.save(backend)

 print(backend.get(Actor,{'imdb_id' : 'nm184'}))
 print('\n')
 print(backend.get(Actor,{'imdb_id' : 'nm434'}))


 OUTPUT -

 Warning: cjson could not be imported, CJsonSerializer will not be
 available.
 Traceback (most recent call last):
   File .\uff.py, line 27, in module
 print(backend.get(Actor,{'imdb_id' : 'nm184'}))
   File C:\Python34\lib\site-packages\blitzdb\backends\file\backend.py,
 line 456, in get
 raise cls.DoesNotExist
 blitzdb.document.DoesNotExist: DoesNotExist(Actor)


 QUESTION -

 Why the output says that Actor doesn't exists when I already added it here
 'actor_1.save(backend)' and 'actor_2.save(backend)'

-- 
https://mail.python.org/mailman/listinfo/python-list


Python 3.4.1 and blitzdb issue

2014-10-22 Thread Juan Christian
Testing code:

CODE -

#!/usr/bin/env

import requests
from blitzdb import Document, FileBackend


API_URL = 'http://api.themoviedb.org/3'
API_KEY = 'ddf30289'


class Actor(Document):
pass


def get_actor(_id):
r = requests.get('{}/person/{}?api_key={}'.format(API_URL, str(_id),
API_KEY))
return r.json()


actor_1 = Actor(get_actor(1))
actor_2 = Actor(get_actor(2))

backend = FileBackend(db.blitz)
actor_1.save(backend)
actor_2.save(backend)

print(backend.get(Actor,{'imdb_id' : 'nm184'}))
print('\n')
print(backend.get(Actor,{'imdb_id' : 'nm434'}))


OUTPUT -

Warning: cjson could not be imported, CJsonSerializer will not be available.
Traceback (most recent call last):
  File .\uff.py, line 27, in module
print(backend.get(Actor,{'imdb_id' : 'nm184'}))
  File C:\Python34\lib\site-packages\blitzdb\backends\file\backend.py,
line 456, in get
raise cls.DoesNotExist
blitzdb.document.DoesNotExist: DoesNotExist(Actor)


QUESTION -

Why the output says that Actor doesn't exists when I already added it here
'actor_1.save(backend)' and 'actor_2.save(backend)'
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Is there an easy way to control indents in Python

2014-10-20 Thread Juan Christian
Ok, new code using ?:

import sqlite3

db = sqlite3.connect('db.sqlite')


def create_db():
db.execute('''
CREATE TABLE TOPICS(
ID INT PRIMARY KEY NOT NULL,
URL VARCHAR NOT NULL,
AUTHOR VARCHAR NOT NULL,
MESSAGE VARCHAR NOT NULL
);
''')


def insert_db(_id, url, author, message):
db.execute(INSERT INTO TOPICS (ID, URL, AUTHOR, MESSAGE) VALUES (?, ?,
?, ?), (_id, url, author, message))
db.commit()


def get_db(_id):
cursor = db.execute(SELECT ID, URL, AUTHOR, MESSAGE FROM TOPICS WHERE ID =
?, (_id))
return cursor.fetchone()


if __name__ == '__main__':
create_db()
insert_db(12, 'abc.com', 'a', 'b')
print(get_db(12))
db.close()

-

But now when I execute I get

Traceback (most recent call last):
  File .\sql.py, line 30, in module
print(get_db(12))
  File .\sql.py, line 23, in get_db
cursor = db.execute(SELECT ID, URL, AUTHOR, MESSAGE FROM TOPICS WHERE
ID = ?, (_id))
ValueError: parameters are of unsupported type

-

And the second time, again, I get

Traceback (most recent call last):
  File .\sql.py, line 28, in module
create_db()
  File .\sql.py, line 14, in create_db
''')
sqlite3.OperationalError: table TOPICS already exists

On Mon, Oct 20, 2014 at 3:57 PM, Ian Kelly ian.g.ke...@gmail.com wrote:

 On Mon, Oct 20, 2014 at 11:54 AM, Ian Kelly ian.g.ke...@gmail.com wrote:
  On Mon, Oct 20, 2014 at 9:54 AM, Simon Kennedy sffjun...@gmail.com
 wrote:
  Not having ever attempted to go beyond even the basics of Perl, the
 aspect that causes me to refer to Perl 'dismissively' as well comment in
 this thread, is that I don't find Perl to be an aesthetically pleasing
 language and I consider Python functions which have no blank lines in them
 to be a small step towards Perl.
 
  Some people do not like Python's indentation rules but for me it's a
 large part of what draws me to program in Python. Spaces for indentation
 and blank lines are both aspects of how I like to program.
 
  I write in Python because I like to, not because I have to.
 
  I think the only reason I might code a function with no blank lines was
 if I was programming in a language that using blank lines caused it to run
 too slowly.
 
  So to be clear, I'm not talking about taking a function like this
  (contrived) example and just removing the blank line:
 
  def find_path(graphdata, start, end):
  edges = map(str.split, lines)
  graph = collections.defaultdict(list)
  for node1, node2, weight in edges:
  graph[node1].append((node[2], int(weight)))
  graph[node2].append((node[1], int(weight)))
 
  open_heap = [(0, (start,))]
  closed_set = set()
  while open_heap:
  cost, path = heapq.heappop(open_heap)
  current_node = path[-1]
  if current_node == end:
  return path
  if current_node in closed_set:
  continue
  for next_node, weight in graph[current_node]:
  heapq.heappush((cost + weight, path + (next_node,)))
  closed_set.add(current_node)
  else:
  raise ValueError(No path from start to end)
 
  Rather, I'm saying that where the blank line is should be the start of
  a new function. There would still be a blank line, just no longer
  inside the function.
 
  Now, maybe you think there should be more blank lines in the above, in
  which case we'll just have to disagree on that point.

 By the way, I didn't test that at all, which is why I've spotted at
 least two bugs in it since sending the message.
 --
 https://mail.python.org/mailman/listinfo/python-list

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Is there an easy way to control indents in Python

2014-10-20 Thread Juan Christian
Sorry guys, my post about SQL was not meant to be here!!!

On Mon, Oct 20, 2014 at 5:43 PM, MRAB pyt...@mrabarnett.plus.com wrote:

 On 2014-10-20 20:04, Juan Christian wrote:

 Ok, new code using ?:

 import sqlite3

 db = sqlite3.connect('db.sqlite')


 def create_db():
  db.execute('''
 CREATE TABLE TOPICS(
 ID INT PRIMARY KEY NOT NULL,
 URL VARCHAR NOT NULL,
 AUTHOR VARCHAR NOT NULL,
 MESSAGE VARCHAR NOT NULL
 );
 ''')


 def insert_db(_id, url, author, message):
  db.execute(INSERT INTO TOPICS (ID, URL, AUTHOR, MESSAGE) VALUES
 (?, ?, ?, ?), (_id, url, author, message))
  db.commit()


 def get_db(_id):
 cursor = db.execute(SELECT ID, URL, AUTHOR, MESSAGE FROM TOPICS WHERE
 ID = ?, (_id))
 return cursor.fetchone()


 if __name__ == '__main__':
 create_db()
 insert_db(12, 'abc.com http://abc.com', 'a', 'b')
 print(get_db(12))
 db.close()

 -

 But now when I execute I get

 Traceback (most recent call last):
File .\sql.py, line 30, in module
  print(get_db(12))
File .\sql.py, line 23, in get_db
  cursor = db.execute(SELECT ID, URL, AUTHOR, MESSAGE FROM TOPICS
 WHERE ID = ?, (_id))
 ValueError: parameters are of unsupported type

 -

  I'm not certain, but I think that the SQL type is called INTEGER, not
 INT.

  And the second time, again, I get

 Traceback (most recent call last):
File .\sql.py, line 28, in module
  create_db()
File .\sql.py, line 14, in create_db
  ''')
 sqlite3.OperationalError: table TOPICS already exists

  That's because you created the table the last time you ran it.

 --
 https://mail.python.org/mailman/listinfo/python-list

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Is there an easy way to control indents in Python

2014-10-14 Thread Juan Christian
Using PyCharm is easy:

File  Settings  (IDE Settings) Editor  Smart Keys  Reformat on paste 
choose Reformat Block

On Tue, Oct 14, 2014 at 11:13 PM, ryguy7272 ryanshu...@gmail.com wrote:

 I'm just learning Python.  It seems like indents are EXTREMELY important.
 I guess, since there are no brackets, everything is controlled by indents.
 Well, I'm reading a couple books on Python now, and in almost all of the
 examples they don't have proper indents, so when I copy/paste the code
 (from the PDF to the IDE) the indents are totally screwed up.  I'm thinking
 that there should be some control, or setting, for this.  I hope.  :)

 I have PyCharm 3.4 and Python 3.4.
 --
 https://mail.python.org/mailman/listinfo/python-list

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Flask and Django

2014-10-12 Thread Juan Christian
Anyone?

On Fri, Oct 10, 2014 at 7:22 PM, Juan Christian juan0christ...@gmail.com
wrote:

 So, I'm already familiar with Flask and I fell comfortable using it, but I
 see that no one uses it in real business, everywhere I look regarding
 jobs and web dev, people always talk about Django, no one mentions Flask,
 no one uses Flask.

 I'm coding a personal tool using Flask but I feel the need to convert it
 to Django because no ones seems to give attention to Flask, but no matter
 what, I don't like, I don't fully understand Django, there are tons of
 conventions, code generations and and too much red tape.

 Maybe that's because I feel the Django doc a bit confuse, I tried reading
 (and practicing!) tutorials, official doc, books, and so on, but I can't
 quite understand the whole thing.

 Is Flask really underestimated? Can you guys mention big name companies
 or people using it? Does it have real value in real world business?

-- 
https://mail.python.org/mailman/listinfo/python-list


Flask and Django

2014-10-10 Thread Juan Christian
So, I'm already familiar with Flask and I fell comfortable using it, but I
see that no one uses it in real business, everywhere I look regarding
jobs and web dev, people always talk about Django, no one mentions Flask,
no one uses Flask.

I'm coding a personal tool using Flask but I feel the need to convert it
to Django because no ones seems to give attention to Flask, but no matter
what, I don't like, I don't fully understand Django, there are tons of
conventions, code generations and and too much red tape.

Maybe that's because I feel the Django doc a bit confuse, I tried reading
(and practicing!) tutorials, official doc, books, and so on, but I can't
quite understand the whole thing.

Is Flask really underestimated? Can you guys mention big name companies
or people using it? Does it have real value in real world business?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Programming for Everybody (Python)

2014-10-02 Thread Juan Christian
I recommend to everyone. Already took one of his courses on Coursera and
he's amazing as a teacher.

On Thu, Oct 2, 2014 at 4:24 PM, Seymore4Head Seymore4Head@hotmail.invalid
wrote:

 Starts in 3 days
 Coursera.org

 About the Course
 This course is specifically designed to be a first programming course
 using the popular Python programming language.  The pace of the course
 is designed to lead to mastery of each of the topics in the class.  We
 will use simple data analysis as the programming exercises through the
 course.Understanding how to process data is valuable for everyone
 regardless of your career.  This course might kindle an interest in
 more advanced programming courses or courses in web design and
 development or just provide skills when you are faced with a bunch of
 data that you need to analyze. You can do the programming assignments
 for the class using a web browser or using your personal computer. All
 required software for the course is free.
 Course Syllabus
 Week One: Introduction - Why we program?
 Week Two: Variables and Expressions
 Week Three: Conditional code
 Week Four: Functions
 Week Five: Loops and Iteration
 Week Six: Strings
 Week Seven: Files
 Week Eight: Lists
 Week Nine: Dictionaries
 Week Ten: Tuples
 Optional Topic: Regular Expressions

 and.a free book.
 http://www.pythonlearn.com/book.php
 --
 https://mail.python.org/mailman/listinfo/python-list

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Flask and Python 3

2014-09-25 Thread Juan Christian
On Thu, Sep 25, 2014 at 2:28 PM, Chris “Kwpolska” Warrick 
kwpol...@gmail.com wrote:

 It doesn’t matter.  Here, have some wisdom, as provided by the top
 Google hit for “video tutorials suck”:
 https://news.ycombinator.com/item?id=4565615


Using your link, the first comment from user 'arocks':

 If you have been into teaching you would realize that there are different
kinds of learners. Some prefer verbal material, others prefer more visual,
while some others like written material. The vast majority however prefer a
combination of the above. While you can pour over tutorials on how to use
Emacs; just watching a video of a power user using Emacs gives you a
different impression. It is really a completely different experience.

Sometimes it is faster to produce a set of video tutorials than to prepare
well-written documentation. Hence they make a call. However, I agree that
written documentation is the best medium for long term (i.e. smaller,
searchable etc)

So, rather than asking for one medium of instruction to stop, I would
rather encourage the plurality. Let the end-user pick and choose whatever
he/she likes. 


As the guy said, and many others in the comments agree, rather than asking
for one medium of instruction to stop, I would rather encourage the
plurality., and indeed, I prefer plurality, I DO use the official doc, I
don't only see video-tutorials. You don't know me, you don't know my
learning process, so stop imposing what YOU think is right, because what's
right for YOU won't necessarily be for others. No matter what you say, it
won't change, don't try to standardize the learning process, you nor anyone
can do this.



 The thing is, it’s text.  I suppose I could use some text-to-speech
 software to provide you with a video tutorial version of that.


No, you can't, if you think a video tutorial is only that, I'm afraid to
tell that you only saw terrible courses/tutorials in your life.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Flask and Python 3

2014-09-25 Thread Juan Christian
On Thu, Sep 25, 2014 at 3:23 PM, Chris Angelico ros...@gmail.com wrote:

 Actually, what most of the comments are agreeing on is that videos
 need their transcripts. Without them, they suck. Most videos don't
 have any sort of transcript. Ergo, most videos suck.


I'm not talking about 360p 3min kid's tutorial form Youtube here, when I
say video tutorial, it's implied that every video that I talked about have
1. The source-code (if programming/code related), 2. The transcripts and in
some cases even 3. PDF version of the video. In this topic my code went
wrong because I did it on my own, and not crtlc/crtlv from the original
source-code, and it was a stupid typo error


On Thu, Sep 25, 2014 at 3:26 PM, Chris “Kwpolska” Warrick 
kwpol...@gmail.com wrote:

 Also, video tutorials for code (as well as analog books) lack a very
 important feature: copy-paste.  Nobody likes retyping large passages
 of code.  Especially because it’s error-prone.


Coursera, edX, digitaltutors, tv.adobe, tutsplus and many other sites. But,
doesn't matter, if the person watching them is close minding and blindly
hate any type of video tutorial, all these sites, no matter how good they
are will suck for this person...


Any, I think you two fled the point here. I didn't create this topic in
order to talk about video vs text, if you guy want to continue this waste
of time, create a topic and talk everything you want. I'm done here, as I
said, PLURALITY is the key thing, don't try to impose what you think is
right and wrong.

Bye.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Flask and Python 3

2014-09-24 Thread Juan Christian
On Wednesday, September 24, 2014, Chris “Kwpolska” Warrick 
kwpol...@gmail.com wrote:

 Learning from videos is the worst thing you can do.  Use the official
 flask documentation at http://flask.pocoo.org/docs/0.10/quickstart/ —
 it’s much friendlier than a video.

 Also, there is nothing to “learn” — just change the line, and you will
 have more helpful errors.


That's the way I always learned everything. I watch some video courses,
read a book and read the official documentation altogether.

My way can't work for you, but for me it's excellent. And you don't even
know which video/course I'm talking about, so it's gross to tell that
videos are the worst thing...

Anyway, the problem was solved, I already learned lots of new things and
I'm practicing them.
-- 
https://mail.python.org/mailman/listinfo/python-list


Flask and Python 3

2014-09-23 Thread Juan Christian
I'm following a tutorial about Flask using Python 3.4.1, but I'm getting an
error with a dead simple example:

generator.py:

from flask import Flask, render_template


app = Flask(__name__)

@app.route('/')
def index():
return 'Hello World'


@app.route('/blog/post/')
def post():
return render_template('post.html', post_content = Hello, World (from a
template))


if __name__ == '__main__':
app.run(port = 8000)



base.html:

html
head
{% block head %}
titleTest/title
{% endlbock head %}
/head
body

{% block content %}{% endlbock content %}

/body
/html



post.html:

{% extends base.html %}

{% block content %}
!-- Header --
div id = header
h1Blog post title/h1
h2Subtitle/h2
h3 id = datedate/h3
/div

!-- Contect --
div id = content
{{ post_content }}
/div
{% endblock content %}



I typed everything correct,acessing http://localhost:8000 works, but
http://localhost:8000/blog/post/ gives me ' 500 Internal Server Error '.
Why?

Python 3.4.1

Flask (0.10.1)
itsdangerous (0.24)
Jinja2 (2.7.3)
MarkupSafe (0.23)
pip (1.5.6)
setuptools (5.8)
Werkzeug (0.9.6)
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Flask and Python 3

2014-09-23 Thread Juan Christian
On Tue, Sep 23, 2014 at 6:48 PM, John Gordon gor...@panix.com wrote:

  @app.route('/')
  def index():
  return 'Hello World'

 As posted, your code is not indented.  Is this literally how your code
 looks?


The mail screwed the indentation, it's indented in the file.


  {% block content %}{% endlbock content %}

 endlbock is certainly a typo.


Oh my Godd... Yes, that's it, working 100% now. Thanks!
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Flask and Python 3

2014-09-23 Thread Juan Christian
On Tue, Sep 23, 2014 at 8:46 PM, Terry Reedy tjre...@udel.edu wrote:

 Did you use tabs? They are more likely to disappear than spaces.


Yes, I use tabs.

On Tue, Sep 23, 2014 at 9:33 PM, Jon Ribbens jon+use...@unequivocal.co.uk
wrote:

 app.run(port=8000, debug=True) might've made the problem easier to find.


I didn't learn debug with Flask yet. Only in the next videos.
-- 
https://mail.python.org/mailman/listinfo/python-list


Class Inheritance from different module

2014-09-20 Thread Juan Christian
I have the following structure:

Third-party API installed via pip:
steamapi /
app.py
consts.py
core.py
users.py
[...]

My script:
test.py


In the API, the module users.py has a class 'SteamUser' and I want to mimic
it's usage on my code, like this:

import steamapi

[...]

class User(Inheritance from API):
def __init__(self, ID):
steamapi.core.APIConnection(api_key = KEY)
super(  Inheritance SteamUser (ID)) # creates the user using the API

[...]

So that in my code when I need to create a new user, I just call 'usr =
User(XXX)' instead of calling 'usr =
steamapi.user.SteamUser(76561197996416028)', is that possible? And of
course, I want to have access to all the class methods like 'name',
'country_code', 'time_created', 'avatar', 'friends' and so on. And finally,
is that a good approach, pythonic? If not, what would be a good way?
-- 
https://mail.python.org/mailman/listinfo/python-list


Best approach to get data from web page continuously

2014-09-18 Thread Juan Christian
I'll write a python (Python 3.4.1) script to fetch for new data (topics)
from this page (http://steamcommunity.com/app/440/tradingforum)
continuously.

All the topics follow this structure: a class=forum_topic_overlay href=
http://steamcommunity.com/app/440/tradingforum/TOPIC_ID/; /a

It will work like that: I'll get the last topics, do some background
checking regarding user level, inventory value, account age, and other
things, if the user pass in the checking, I'll print some info and links in
the terminal. The only thing I need to know to start is: What's the better
way the get this data? Beautiful Soup 4 + requests? urllib? Others?

Thanks.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: My backwards logic

2014-09-05 Thread Juan Christian
I made this code just for fun and learning, it's working, but would this be
a good approach? Thanks.

import sys


def prime_checker(start = 1, stop = 1):
for number in range(start, stop + 1):
divisors = [(number % x) for x in range(1, number + 1)]
print({n} prime? {r}.format(n = number, r = (divisors.count(0) == 2)))


if __name__ == '__main__':
prime_checker(int(sys.argv[1]), int(sys.argv[2]))


On Fri, Sep 5, 2014 at 2:17 PM, Ian Kelly ian.g.ke...@gmail.com wrote:

 On Fri, Sep 5, 2014 at 11:08 AM, Ethan Furman et...@stoneleaf.us wrote:
  Python's 'for' loop has a handy 'else' extension which is perfect for the
  search-type of 'for' loop:
 
 while True:
  a=random.randrange(1,8)
  print (a)
  for x in range(2,a):
  if a%x==0:
  print (Number is not prime)
  break
  else:
  print (Number is prime)
  wait = input ( *40  + Wait)
 
  Note the two lines I added after the 'break' and before the 'wait'.

 Also note that this construct tends to be particularly sensitive to
 indentation. If you accidentally indent the else block one level too
 many (which your editor may well do for you to helpfully match it up
 with the if), then you'll get a completely different result.

 I would not worry about the else clause as a beginner, as it's
 relatively unique to Python and tends to be somewhat confusing. Use a
 flag or refactor the function instead.
 --
 https://mail.python.org/mailman/listinfo/python-list

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: My backwards logic

2014-09-05 Thread Juan Christian
What's [snip] ??


On Fri, Sep 5, 2014 at 3:48 PM, MRAB pyt...@mrabarnett.plus.com wrote:

 On 2014-09-05 18:35, Juan Christian wrote:

 I made this code just for fun and learning, it's working, but would this
 be a good approach? Thanks.

 import sys


 def prime_checker(start = 1, stop = 1):


 In Python, the standard is to use a half-open range.

  for number in range(start, stop + 1):
 divisors = [(number % x) for x in range(1, number + 1)]
 print({n} prime? {r}.format(n = number, r =
 (divisors.count(0) == 2)))

  You want to know only whether it's prime, so why continue looking after
 finding a factor?


 if __name__ == '__main__':
 prime_checker(int(sys.argv[1]), int(sys.argv[2]))

  [snip]

 --
 https://mail.python.org/mailman/listinfo/python-list

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: My backwards logic

2014-09-05 Thread Juan Christian
@Mark Lawrence: Sorry to ask, but what do you mean by don't top post here,
thanks., I'm not familiar with mailing lists, so I may be doing something
wrong and I don't know.


On Fri, Sep 5, 2014 at 4:54 PM, Mark Lawrence breamore...@yahoo.co.uk
wrote:

 On 05/09/2014 20:34, Juan Christian wrote:

 What's [snip] ??


 As in cut out or chopped out such that some of the original text has been
 removed.  And please don't top post here, thanks.

 --
 My fellow Pythonistas, ask not what our language can do for you, ask
 what you can do for our language.

 Mark Lawrence

 --
 https://mail.python.org/mailman/listinfo/python-list

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Posting style: interleaved responses (was: My backwards logic)

2014-09-05 Thread Juan Christian
On Fri, Sep 5, 2014 at 11:37 PM, Ben Finney ben+pyt...@benfinney.id.au
wrote:

 Juan Christian juan0christ...@gmail.com writes:

  @Mark Lawrence: Sorry to ask, but what do you mean by don't top post
  here, thanks., I'm not familiar with mailing lists, so I may be doing
  something wrong and I don't know.

 Please post your responses interleaved with the quoted material to
 which you're responding. See the article on “interleaved style”
 URL:https://en.wikipedia.org/wiki/Posting_style#Interleaved_style. And
 trim any quoted material to which you're not responding, so your message
 only contains relevant material.

 --
  \“Human reason is snatching everything to itself, leaving |
   `\   nothing for faith.” —Bernard of Clairvaux, 1090–1153 CE |
 _o__)  |
 Ben Finney

 --
 https://mail.python.org/mailman/listinfo/python-list


Like that? I'm using gmail so it automatically put the text in the [...]
icon.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python is going to be hard

2014-09-03 Thread Juan Christian
I'm learning Python using this mailist, and the Tutor mailist, reading the
docs and watching this course, Python Fundamentals (
http://www.pluralsight.com/training/Courses/TableOfContents/python-fundamentals
).

Python is really easy and useful, OP don't blame the language because you
didn't understood it yet, just persist.


On Wed, Sep 3, 2014 at 3:33 PM, Ethan Furman et...@stoneleaf.us wrote:

 On 09/03/2014 11:10 AM, Seymore4Head wrote:

 import math
 import random
 import sys
 b=[]
 steve = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89]
 for x in steve:
  print (steve[x])

 Traceback (most recent call last):
File C:\Functions\blank.py, line 7, in module
  print (steve[x])
 IndexError: list index out of range


 Python will be incredibly hard if you don't read any of the docs or
 tutorials available.

 --
 ~Ethan~
 --
 https://mail.python.org/mailman/listinfo/python-list

-- 
https://mail.python.org/mailman/listinfo/python-list


PySide 1.2.2 and Python 3.4.1 - native Qt signal is not callable

2014-08-30 Thread Juan Christian
Hello everyone, I have a question regarding PySide 1.2.2 and Python 3.4.1

I have this code http://pastebin.com/5NXd4Jkk that I made following a Python
tutorial https://www.youtube.com/watch?v=8D_aEYiBU2c, mine is a bit
different because the tutorial is a bit old, and I'm trying to use Python
newest features .

As I read in the doc, PySide Signal and Slots now work differently, and I'm
trying to use this new way (lines 32 - 34).

But, as you guys can see in the pastebin link, it's not working, but I
don't have a clue why. I hope someone can explain me what I did wrong.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: PySide 1.2.2 and Python 3.4.1 - native Qt signal is not callable

2014-08-30 Thread Juan Christian
Yes, indeed, my code was a mess!

I did a clear code here (http://pastebin.com/XsVLSVky) that's fully
working, thanks!


2014-08-30 16:05 GMT-03:00 MRAB pyt...@mrabarnett.plus.com:

 On 2014-08-30 14:35, Juan Christian wrote:

 Hello everyone, I have a question regarding PySide 1.2.2 and Python 3.4.1

 I have this code http://pastebin.com/5NXd4Jkk that I made following a
 Python tutorial https://www.youtube.com/watch?v=8D_aEYiBU2c, mine is a

 bit different because the tutorial is a bit old, and I'm trying to use
 Python newest features .

 As I read in the doc, PySide Signal and Slots now work differently, and
 I'm trying to use this new way (lines 32 - 34).

 But, as you guys can see in the pastebin link, it's not working, but I
 don't have a clue why. I hope someone can explain me what I did wrong.

  Judging from the traceback, the problem is that you're trying to call a
 signal, but it's not callable.

 After a brief look, I found this:

 https://qt-project.org/wiki/Signals_and_Slots_in_PySide

 To me it looks like you should be doing this instead (untested):

 self.fromComboBox.currentIndexChanged.connect(self.update_ui)

 --
 https://mail.python.org/mailman/listinfo/python-list

-- 
https://mail.python.org/mailman/listinfo/python-list


Error reading from 'urllib.request' and iterating over lines

2014-08-30 Thread Juan Christian
My code: http://pastebin.com/CBgVvT4n

Line 25 returns the text correctly [1], but it seems not being parsed to
line 27-28 correctly. This is just a training program that I'm doing
following some books/tutorials/docs, nothing special.

[1] Output from line 25: http://pastebin.com/HSbAtDHQ

Python 3.4.1
PySide 1.2.2
-- 
https://mail.python.org/mailman/listinfo/python-list