Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #58512 > unrolled thread

Help me with this code PLEASE

Started byNick the Gr33k <nikos.gr33k@gmail.com>
First post2013-11-05 19:06 +0200
Last post2013-11-05 19:32 -0500
Articles 13 on this page of 33 — 16 participants

Back to article view | Back to comp.lang.python


Contents

  Help me with this code PLEASE Nick the Gr33k <nikos.gr33k@gmail.com> - 2013-11-05 19:06 +0200
    Re: Help me with this code PLEASE Antoon Pardon <antoon.pardon@rece.vub.ac.be> - 2013-11-05 18:23 +0100
    Re: Help me with this code PLEASE mm0fmf <none@mailinator.com> - 2013-11-05 17:33 +0000
    Re: Help me with this code PLEASE Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-11-05 17:41 +0000
      Re: Help me with this code PLEASE Antoon Pardon <antoon.pardon@rece.vub.ac.be> - 2013-11-05 18:53 +0100
      Re: Help me with this code PLEASE Nick the Gr33k <nikos.gr33k@gmail.com> - 2013-11-05 19:59 +0200
        Re: Help me with this code PLEASE Tobiah <toby@tobiah.org> - 2013-11-05 10:11 -0800
          Re: Help me with this code PLEASE Joel Goldstick <joel.goldstick@gmail.com> - 2013-11-05 14:01 -0500
    Re: Help me with this code PLEASE Denis McMahon <denismfmcmahon@gmail.com> - 2013-11-05 18:02 +0000
      Re: Help me with this code PLEASE Nick the Gr33k <nikos.gr33k@gmail.com> - 2013-11-05 20:09 +0200
        Re: Help me with this code PLEASE Denis McMahon <denismfmcmahon@gmail.com> - 2013-11-05 20:10 +0000
        Re: Help me with this code PLEASE Cameron Simpson <cs@zip.com.au> - 2013-11-06 09:31 +1100
        Re: Help me with this code PLEASE bob gailer <bgailer@gmail.com> - 2013-11-05 18:15 -0500
        Re: Help me with this code PLEASE Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-11-05 23:36 +0000
    Re: Help me with this code PLEASE John Gordon <gordon@panix.com> - 2013-11-05 20:19 +0000
      Re: Help me with this code PLEASE Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-11-05 21:17 +0000
      Re: Help me with this code PLEASE Nick the Gr33k <nikos.gr33k@gmail.com> - 2013-11-05 23:26 +0200
        Re: Help me with this code PLEASE John Gordon <gordon@panix.com> - 2013-11-05 22:06 +0000
          Re: Help me with this code PLEASE Nick the Gr33k <nikos.gr33k@gmail.com> - 2013-11-06 00:28 +0200
            Re: Help me with this code PLEASE Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-11-05 22:44 +0000
            Re: Help me with this code PLEASE John Gordon <gordon@panix.com> - 2013-11-05 22:54 +0000
              Re: Help me with this code PLEASE Nick the Gr33k <nikos.gr33k@gmail.com> - 2013-11-06 03:14 +0200
                Re: Help me with this code PLEASE Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-11-06 08:49 +0000
                Re: Help me with this code PLEASE Joel Goldstick <joel.goldstick@gmail.com> - 2013-11-06 08:57 -0500
        Re: Help me with this code PLEASE Antoon Pardon <antoon.pardon@rece.vub.ac.be> - 2013-11-06 09:27 +0100
      Re: Help me with this code PLEASE Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-11-05 21:42 +0000
      Re: Help me with this code PLEASE Chris Angelico <rosuav@gmail.com> - 2013-11-06 09:03 +1100
    Re: Help me with this code PLEASE Piet van Oostrum <piet@vanoostrum.org> - 2013-11-05 18:15 -0400
      Re: Help me with this code PLEASE Nick the Gr33k <nikos.gr33k@gmail.com> - 2013-11-06 00:35 +0200
        Re: Help me with this code PLEASE Denis McMahon <denismfmcmahon@gmail.com> - 2013-11-06 00:45 +0000
          Re: Help me with this code PLEASE Ben Finney <ben+python@benfinney.id.au> - 2013-11-06 12:46 +1100
          Re: Help me with this code PLEASE Grant Edwards <invalid@invalid.invalid> - 2013-11-06 14:50 +0000
      Re: Help me with this code PLEASE Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2013-11-05 19:32 -0500

Page 2 of 2 — ← Prev page 1 [2]


#58534

FromJohn Gordon <gordon@panix.com>
Date2013-11-05 22:54 +0000
Message-ID<l5bsvh$q6q$1@reader1.panix.com>
In reply to#58531
In <l5brem$trk$1@dont-email.me> Nick the Gr33k <nikos.gr33k@gmail.com> writes:

> The code i provided only worked once before it failed and managed to 
> store this:
> 	
> counterID,host,refs,city,userOS,browser,visits,hits,download
> -------------------------------------------------------------
> 1, 176-92-96-218.adsl.cyta.gr, Europe/Athens, Windows, Chrome, 
> 0000-00-00 00:00:00, 1, ''

You've got a data inconsistancy here.  You give nine column names, but
only eight values.  It's impossible to tell which value belongs to which
column.  Which value is missing?

> 'visit's column is full of zeroes. Perhaps this is considered  as Null 
> for Python?

Python does not consider zero to be a null value.  (It will compare as
equal to False, but that's not the same.)

> But ref is also null, why the code didn't complain for 'ref' which is 
> retrieved just before 'visits'?

Are you sure refs is null?  According to the sample values you gave, refs
is 'Europe/Athens'.

-- 
John Gordon         Imagine what it must be like for a real medical doctor to
gordon@panix.com    watch 'House', or a real serial killer to watch 'Dexter'.

[toc] | [prev] | [next] | [standalone]


#58541

FromNick the Gr33k <nikos.gr33k@gmail.com>
Date2013-11-06 03:14 +0200
Message-ID<l5c55h$maf$1@dont-email.me>
In reply to#58534
Στις 6/11/2013 12:54 πμ, ο/η John Gordon έγραψε:
>> The code i provided only worked once before it failed and managed to
>> store this:
>> 	
>> counterID,host,refs,city,userOS,browser,visits,hits,download
>> -------------------------------------------------------------
>> 1, 176-92-96-218.adsl.cyta.gr, Europe/Athens, Windows, Chrome,
>> 0000-00-00 00:00:00, 1, ''
> You've got a data inconsistancy here.  You give nine column names, but
> only eight values.  It's impossible to tell which value belongs to which
> column.  Which value is missing?


Yes, you have a point but thats why because 'refs' was an empty string 
for some reason and i have should have made this clear by putting a '' 
like i did with the 'downloads' at the end.

So it is not a matter of inconsistency.
Its weird though why it was stored this way, refs and downloads that is 
as an empty strings.

How, do i i proceed?

[toc] | [prev] | [next] | [standalone]


#58557

FromMark Lawrence <breamoreboy@yahoo.co.uk>
Date2013-11-06 08:49 +0000
Message-ID<mailman.2077.1383727774.18130.python-list@python.org>
In reply to#58541
On 06/11/2013 01:14, Nick the Gr33k wrote:
>
> How, do i i proceed?

If at first you don't succeed, keep asking on comp.lang.python until 
someone gives me the completely bodged solution that I keep asking for 
even if it's complete nonsense.

-- 
Python is the second best programming language in the world.
But the best has yet to be invented.  Christian Tismer

Mark Lawrence

[toc] | [prev] | [next] | [standalone]


#58560

FromJoel Goldstick <joel.goldstick@gmail.com>
Date2013-11-06 08:57 -0500
Message-ID<mailman.2079.1383746242.18130.python-list@python.org>
In reply to#58541
On Wed, Nov 6, 2013 at 3:49 AM, Mark Lawrence <breamoreboy@yahoo.co.uk> wrote:
> On 06/11/2013 01:14, Nick the Gr33k wrote:
>>
>>
>> How, do i i proceed?
>
>
> If at first you don't succeed, keep asking on comp.lang.python until someone
> gives me the completely bodged solution that I keep asking for even if it's
> complete nonsense.
>
>
> --
> Python is the second best programming language in the world.
> But the best has yet to be invented.  Christian Tismer
>
> Mark Lawrence
>
> --
> https://mail.python.org/mailman/listinfo/python-list

Nikos,

I believe we are passed the time again where your enquiries slip from
legitimate questions to trolling behavior.  As was pointed out you
aren't close to any solution.  You should go off taking the advice and
tutoring you have had here, do some reading (yes, actually learn and
understand something), perhaps start from scratch reading basics of
computer programming, databases, html, unicode, operating systems, web
servers, etc. and come back when you have a solid basis to ask a
question.

I take my profession seriously.  Its fun, but it takes a lot of
reading and studying and practice to be good at it.  The fact that you
even presume that you are doing what software designers, or engineers
or programmers do to ply the craft is disgusting.  Its not that you
don't know, its that you don't know and are an arrogant idiot to
assume that you do.

Your threads all end up being a very poor man's version of the movie
Ground Hog Day.  The fact that you don't recognize how rude and
insulting you are, and how little you bring to the discussion will
inevitably lead to more personal attacks since you aren't holding up
your end of the technical back and forth.

Your repeated behavior of starting new threads is just a boring
childish method to demand attention.  You have our attention.  I
believe that most of us if not all of us think you are the most
aggravating, incompetent, rude, needy, manipulating,  person we have
ever seen online ever.  Go away, and come back (months from now at
least) when you have some redeeming human qualities.

-- 
Joel Goldstick
http://joelgoldstick.com

[toc] | [prev] | [next] | [standalone]


#58555

FromAntoon Pardon <antoon.pardon@rece.vub.ac.be>
Date2013-11-06 09:27 +0100
Message-ID<mailman.2076.1383726452.18130.python-list@python.org>
In reply to#58526
Op 05-11-13 22:26, Nick the Gr33k schreef:

> I know i'm close to solution, i can feel it but i have some issues.
> The code we arr discussing is the following:

No you are not. You are just doing random changes, without any
understanding. If you had followed my suggestion and actually
read the documentation of fetchone, you would have realised
this wouldn't have worked either.

Your resistance to reading the documentation is making you lose
more time than you hoped to win by just going ahead and trying
things blindly.

> [Tue Nov 05 23:21:52 2013] [error] [client 176.92.96.218]   File
> "/home/nikos/public_html/cgi-bin/metrites.py", line 274, in <module>
> [Tue Nov 05 23:21:52 2013] [error] [client 176.92.96.218]     visit =
> visit.split()
> [Tue Nov 05 23:21:52 2013] [error] [client 176.92.96.218]
> AttributeError: 'NoneType' object has no attribute 'split'

This is essentially the same error you had before. You have an object
of NoneType where you expect something different. Changing your code
to use split instead of iteration won't change the fact that you have
an object of NoneType.

-- 
Antoon Pardon

[toc] | [prev] | [next] | [standalone]


#58527

FromMark Lawrence <breamoreboy@yahoo.co.uk>
Date2013-11-05 21:42 +0000
Message-ID<mailman.2062.1383687750.18130.python-list@python.org>
In reply to#58524
On 05/11/2013 21:17, Mark Lawrence wrote:
> On 05/11/2013 20:19, John Gordon wrote:
>> In <l5b8if$4k1$1@dont-email.me> Nick the Gr33k <nikos.gr33k@gmail.com>
>> writes:
>>
>>> IAM STRUGGLING WITH IT 2 DAYS NOW AND I CANNOT GET IT TO WORK.
>>
>>> ALL I WANT IT TO DO IS JUST
>>
>>> 1. RETRIEVE 3 COLUMNS THAT CONSIST OF 3 LONG STRINGS
>>> 2. CONVERT LONG STRINGS TO LISTS
>>> 3. ADD SOME CURRENT VALUES TO THOSE LISTS
>>> 4. CONVERT FROM LISTS TO LONG STRINGS SO I CAN STORE SUCCESSFULLY LIST
>>> PYTHON DATATYPE TO MYSQL SCALAR STRING.
>>
>>> EVERYHTIGN I TRIED FAILED.
>>
>> How did it fail?
>>
>> Error message?
>> No results at all?
>> Different results than you wanted?  If so, how did they differ?
>>
>
> Dear John,
>
> This approach has already been tried by Dave Angel, Steven D'Aprano and
> Chris Angelico amongst others and has failed dismally so why should you
> be any different?
>
> I've taken a different approach. I've put the contract out to tender and
> hereby give you the winners
> http://www.mudefordwoodcommunitycentre.co.uk/playgroup-and-tiny-tots/
>
> Part of the rationale is that they're literally 100 yards from my front
> door so communicating with them effectively should be extremely easy.
> This will be particularly useful when it comes down to debugging such
> difficult issues as "> TypeError: 'NoneType' object is not iterable".
>
> I'm looking forward to working in partnership with them and am convinced
> that within a few days all of Nikos' problems will have been solved.
>

Oh dear it looks as if we might have to renegotiate the contract as I 
understand that we've an almost intractable problem to solve it's 
"AttributeError: 'NoneType' object has no attribute 'split'".

-- 
Python is the second best programming language in the world.
But the best has yet to be invented.  Christian Tismer

Mark Lawrence

[toc] | [prev] | [next] | [standalone]


#58528

FromChris Angelico <rosuav@gmail.com>
Date2013-11-06 09:03 +1100
Message-ID<mailman.2063.1383689000.18130.python-list@python.org>
In reply to#58524
On Wed, Nov 6, 2013 at 8:17 AM, Mark Lawrence <breamoreboy@yahoo.co.uk> wrote:
> I've taken a different approach. I've put the contract out to tender and
> hereby give you the winners
> http://www.mudefordwoodcommunitycentre.co.uk/playgroup-and-tiny-tots/

Sounds good! But I don't see a list of their technologies - do they
use open source tools like Python, or is it proprietary stuff like
Fisher-Price(tm) "My First Website"? The latter is probably sufficient
for these tasks, but I would hope that your contractors are able to
master real-world problems too.

Nikos, once again you are getting yourself into a tizz over this,
because the problem is urgent to you. You need to stop programming
professionally and make it a hobby, so that you remove the time
pressure. You cope badly with pressure, so why torture yourself? Get
into a completely different industry for your day job, and do all your
programming in the evenings. You'll find lots of things easier and
less stressful.

ChrisA

[toc] | [prev] | [next] | [standalone]


#58530

FromPiet van Oostrum <piet@vanoostrum.org>
Date2013-11-05 18:15 -0400
Message-ID<m238na1oma.fsf@cochabamba.vanoostrum.org>
In reply to#58512
Nick the Gr33k <nikos.gr33k@gmail.com> writes:

>
> IAM STRUGGLING WITH IT 2 DAYS NOW AND I CANNOT GET IT TO WORK.
>
> ALL I WANT IT TO DO IS JUST
>
> 1. RETRIEVE 3 COLUMNS THAT CONSIST OF 3 LONG STRINGS
> 2. CONVERT LONG STRINGS TO LISTS
> 3. ADD SOME CURRENT VALUES TO THOSE LISTS
> 4. CONVERT FROM LISTS TO LONG STRINGS SO I CAN STORE SUCCESSFULLY LIST
> PYTHON DATATYPE TO MYSQL SCALAR STRING.
>
> EVERYHTIGN I TRIED FAILED.

Then why don't you use the simple solution: use a relational database to store the data?
-- 
Piet van Oostrum <piet@vanoostrum.org>
WWW: http://pietvanoostrum.com/
PGP key: [8DAE142BE17999C4]

[toc] | [prev] | [next] | [standalone]


#58532

FromNick the Gr33k <nikos.gr33k@gmail.com>
Date2013-11-06 00:35 +0200
Message-ID<l5brs9$1n3$1@dont-email.me>
In reply to#58530
Στις 6/11/2013 12:15 πμ, ο/η Piet van Oostrum έγραψε:
> Nick the Gr33k <nikos.gr33k@gmail.com> writes:
>
>>
>> IAM STRUGGLING WITH IT 2 DAYS NOW AND I CANNOT GET IT TO WORK.
>>
>> ALL I WANT IT TO DO IS JUST
>>
>> 1. RETRIEVE 3 COLUMNS THAT CONSIST OF 3 LONG STRINGS
>> 2. CONVERT LONG STRINGS TO LISTS
>> 3. ADD SOME CURRENT VALUES TO THOSE LISTS
>> 4. CONVERT FROM LISTS TO LONG STRINGS SO I CAN STORE SUCCESSFULLY LIST
>> PYTHON DATATYPE TO MYSQL SCALAR STRING.
>>
>> EVERYHTIGN I TRIED FAILED.
>
> Then why don't you use the simple solution: use a relational database to store the data?
>


-- 
How you mean?

Up until now i was using for years MySQL.
Now i realizes i just cannot store lists into it's columns because it 
does not support a collection datatype.

perhaps its time to use postgresql so to avoid these coversions?

does postgresql support "collection" columns?

and is its synta

[toc] | [prev] | [next] | [standalone]


#58540

FromDenis McMahon <denismfmcmahon@gmail.com>
Date2013-11-06 00:45 +0000
Message-ID<l5c3ek$843$1@dont-email.me>
In reply to#58532
On Wed, 06 Nov 2013 00:35:56 +0200, Nick the Gr33k wrote:

> Now i realizes i just cannot store lists into it's columns because it
> does not support a collection datatype.

All databases support storing of collections, but *NOT THE WAY YOU WANT 
TO DO IT*

You refuse to do it the proper way, so you have to bodge a solution .... 
oh wait .... I'm having a flashback here ....

You have been told several times by several people how to do this 
properly. You insist on using your bodged up solution instead. OK, we'll 
all try and help you bodge up a solution, but I will tell you now, in 
advance, in very clear terms:

*ONE DAY YOUR BODGED UP SOLUTION WILL BREAK BECAUSE THE TOTAL LIST OF 
TORRENTS THAT A USER HAS DOWNLOADED, WHEN PACKAGED INTO A STRING, WILL BE 
BIGGER THAN THE DATABASE STRING FIELD YOU ASSIGNED*

There may be another issue that you need to consider.

Supposing a torrent file name is 40 characters long. Supposing a user 
downloads up to 20 torrents a day. That means in one year, their list 
will contain 7300 entries, and the character string in the database will 
be 365 * 20 * 40 + 365 * 20 - 1 = 299299 characters.

And you're going to convert this huge string into a list and then back 
into a string 20 times a day for every user just to add another 40 
characters to the end.

Do you expect 100 users? 1,000? 10,000? 100,000?

Let's assume that you have a million users. In a year, every day you're 
reading and writing about 6000 Gbytes a day from and to the database.

Holy smoke batman, that's a lot of data.

Or you could use the database properly, and just write the 40 byte 
torrent file name to the database with a pointer to the user's record 
every time a user downloads another torrent.

-- 
Denis McMahon, denismfmcmahon@gmail.com

[toc] | [prev] | [next] | [standalone]


#58543

FromBen Finney <ben+python@benfinney.id.au>
Date2013-11-06 12:46 +1100
Message-ID<mailman.2070.1383702381.18130.python-list@python.org>
In reply to#58540
Denis McMahon <denismfmcmahon@gmail.com> writes:

> You have been told several times by several people how to do this 
> properly. You insist on using your bodged up solution instead. OK, we'll 
> all try and help you bodge up a solution[…]

Why? No-one here is obligated to help with implementing a solution we
agree is bad.

Now that helpful suggestions have been offered, and the OP continues to
obstinately refuse to learn, why not leave it there? Why not leave this
person to his own obstinacy and stop giving him the attention he
demands?

-- 
 \     “Computers are useless. They can only give you answers.” —Pablo |
  `\                                                           Picasso |
_o__)                                                                  |
Ben Finney

[toc] | [prev] | [next] | [standalone]


#58563

FromGrant Edwards <invalid@invalid.invalid>
Date2013-11-06 14:50 +0000
Message-ID<l5dl07$90k$1@reader1.panix.com>
In reply to#58540
On 2013-11-06, Denis McMahon <denismfmcmahon@gmail.com> wrote:
> On Wed, 06 Nov 2013 00:35:56 +0200, Nick the Gr33k wrote:
>
>> Now i realizes i just cannot store lists into it's columns because it
>> does not support a collection datatype.
>
> All databases support storing of collections, but *NOT THE WAY YOU WANT 
> TO DO IT*
>
> You refuse to do it the proper way, so you have to bodge a solution .... 
> oh wait .... I'm having a flashback here ....

To quote the great Casey Stengel "it's deja vu all over again".

http://www.bostonbaseball.com/whitesox/baseball_extras/yogi.html

-- 
Grant Edwards               grant.b.edwards        Yow! I feel like a wet
                                  at               parking meter on Darvon!
                              gmail.com            

[toc] | [prev] | [next] | [standalone]


#58539

FromDennis Lee Bieber <wlfraed@ix.netcom.com>
Date2013-11-05 19:32 -0500
Message-ID<mailman.2069.1383697954.18130.python-list@python.org>
In reply to#58530
On Tue, 05 Nov 2013 18:15:57 -0400, Piet van Oostrum <piet@vanoostrum.org>
declaimed the following:

>Nick the Gr33k <nikos.gr33k@gmail.com> writes:
>
>>
>> IAM STRUGGLING WITH IT 2 DAYS NOW AND I CANNOT GET IT TO WORK.
>>
>> ALL I WANT IT TO DO IS JUST
>>
>> 1. RETRIEVE 3 COLUMNS THAT CONSIST OF 3 LONG STRINGS
>> 2. CONVERT LONG STRINGS TO LISTS
>> 3. ADD SOME CURRENT VALUES TO THOSE LISTS
>> 4. CONVERT FROM LISTS TO LONG STRINGS SO I CAN STORE SUCCESSFULLY LIST
>> PYTHON DATATYPE TO MYSQL SCALAR STRING.
>>
>> EVERYHTIGN I TRIED FAILED.
>
>Then why don't you use the simple solution: use a relational database to store the data?

	He /is/ using a relational database (MySQL, please, no complaints)...
He just doesn't understand what it means to be a relational database:
normalization, primary keys, joins, etc. -- so he is treating the database
like a flat file and trying to fit into one field multi-valued data.
-- 
	Wulfraed                 Dennis Lee Bieber         AF6VN
    wlfraed@ix.netcom.com    HTTP://wlfraed.home.netcom.com/

[toc] | [prev] | [standalone]


Page 2 of 2 — ← Prev page 1 [2]

Back to top | Article view | comp.lang.python


csiph-web