Re: [Tutor] REQUIRED SUPPORT FOR CODE

2019-07-25 Thread john fabiani

Dabo has an AutoComplete method.  You review how it was done.

Johnf

On 7/25/2019 4:26 PM, Alan Gauld via Tutor wrote:

On 25/07/2019 16:58, NITESH KUMAR wrote:

I want to make Autocomplete searchbox using database .Please suggest me the
code for this.

Since you tell us next to noting we can only make wild suggestions.
Try to find a project that does the same thing - ideally one written
in Python (assuming that you are using python?) and see how it does it.

Failing that provide us with a lot more detail.
What kind of application is it? - Desktop? GUI? command line? Web based?
Mobile app?

What tools are you using - specifically any web or GUI toolkits.

What OS and python versions are you using?

What kind of database?

How do you anticipate this would work? Give us some examples?
#

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] how to get the weeks of a month

2019-03-04 Thread john fabiani



On 3/4/19 2:47 PM, David Rock wrote:

On Mar 4, 2019, at 16:30, Ben Finney  wrote:

john fabiani  writes:


My understanding is - a week starts on Monday and ends on Sunday.

That's behaviour specific to a timezone. Which one are you using, and
does your program know to consult the timezone data for when a week
begins and ends?


That’s why I said "Which I’m sure is just a question of “defining the start of 
the week” properly.”  “Properly” is in the eye of the beholder.  As long as it’s 
performing the way you expect it to perform, you should be fine.  If all I saw was 
the output you had, I’d think something was broken because I think in terms of first 
day being Sunday, so maybe include a note in the output what the First day of the 
week is if that’s appropriate?


—
David Rock
da...@graniteweb.com



I didn't think about that.  I will in the future.
Thanks,
Johnf
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] how to get the weeks of a month

2019-03-04 Thread john fabiani



On 3/4/19 1:35 PM, David Rock wrote:

On Mar 4, 2019, at 15:28, john fabiani  wrote:

I knew there was a simple why to get it done!  But where is it off my a day?


comparing

$ cal
  March 2019
Su Mo Tu We Th Fr Sa
 1  2
  3  4  5  6  7  8  9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
31

to

import calendar as cal
cal.monthcalendar(2019,3)
[[0, 0, 0, 0, 1, 2, 3], [4, 5, 6, 7, 8, 9, 10], [11, 12, 13, 14, 15, 16,
17], [18, 19, 20, 21, 22, 23, 24], [25, 26, 27, 28, 29, 30, 31]]

I see the first element of the array is
[0, 0, 0, 0, 1, 2, 3]

where I would have expected
[0, 0, 0, 0, 0, 1, 2]

Which I’m sure is just a question of “defining the start of the week” properly, 
but if you just took it as-is, Mar 1 would be Thursday, not Friday if you 
translated literally.


—
David Rock
da...@graniteweb.com
My understanding is - a week starts on Monday and ends on Sunday. So 
that looks correct.  Below I use a max function but I wonder if I should 
use a min function too.  Recall I am looking for the string of the dates 
for the week.


Here is my code:
import datetime
import calendar


#get the weeks of a month to get the dates to display
tday = datetime.datetime(2020,03,01)

weeksInMonth =calendar.monthcalendar(tday.year, tday.month)
lastdayof1stweek = weeksInMonth[0][6]
firstweek = tday.strftime("%m-%d_%Y")+ " - "+ 
datetime.datetime(tday.year, tday.month, 
lastdayof1stweek).strftime("%m-%d-%Y")

print firstweek
for i in range(len(weeksInMonth)):
    if i == 0:
    continue
    firstday = weeksInMonth[i][0]
    lastday =  max(weeksInMonth[i])
    weekstr = datetime.datetime(tday.year, tday.month, 
firstday).strftime("%m-%d-%Y") + ' - ' + datetime.datetime(tday.year, 
tday.month, lastday).strftime("%m-%d-%Y")

    print weekstr

def max(arr):
    max_ = arr[0]
    for item in arr:
    if item > max_:
    max_ = item
    return max_
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] how to get the weeks of a month

2019-03-04 Thread john fabiani



On 3/4/19 1:15 PM, David Rock wrote:

On Mar 4, 2019, at 13:19, Alan Gauld via Tutor  wrote:

On 04/03/2019 18:54, john fabiani wrote:


I need to print out the weeks of the month - given any month and any year.

I'm not totally clear how you define a week.

EDIT: OK I see the comment at the end now.


For example this month would have:

3/1/2019 - 3/3/2019   # notice that this a short week
3/4/2019 - 3/10/2019
3/11/2019 - 3/17/2019
3/18/2019 - 3/24/2019
3/25/2019 - 3/31/2019  # also this can be a short week as in April 2019
last week would be 4/29/2019 - 4/30-2019

What I think he’s shooting for is something similar to cal output

$ cal
  March 2019
Su Mo Tu We Th Fr Sa
 1  2
  3  4  5  6  7  8  9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
31



So what I think you want is to

start with the first day and print each day up to Sunday.
Newline
print the current date up to sunday
newline
repeat until you run out of days in the month.



import calendar as cal
cal.monthcalendar(2019,3)

[[0, 0, 0, 0, 1, 2, 3], [4, 5, 6, 7, 8, 9, 10], [11, 12, 13, 14, 15, 16,
17], [18, 19, 20, 21, 22, 23, 24], [25, 26, 27, 28, 29, 30, 31]]
That looks close to what you want?


That seems close, but off by a day?


—
David Rock
da...@graniteweb.com

I knew there was a simple why to get it done!  But where is it off my a day?

Johnf
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


[Tutor] how to get the weeks of a month

2019-03-04 Thread john fabiani

Hi everyone,

I'm not exactly a newbie but I can't seem to solve this problem.

I need to print out the weeks of the month - given any month and any year.

For example this month would have:

3/1/2019 - 3/3/2019   # notice that this a short week
3/4/2019 - 3/10/2019
3/11/2019 - 3/17/2019
3/18/2019 - 3/24/2019
3/25/2019 - 3/31/2019  # also this can be a short week as in April 2019 
last week would be 4/29/2019 - 4/30-2019


I have tried using isocalendar, dateutil, and just plain datetime.

I get close but no real solution. Google wasn't much help either.  So I 
thought I'd ask here - you have been helpful in the past.  And no at my 
age I am not attending school - so this not my homework.


Johnf

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] I have a problem with def

2018-02-23 Thread john fabiani

I don't what you are doing but

it should be at least

def func():

notice the colon at the end.

Johnf


On 02/22/2018 02:16 PM, David Bauer wrote:

it doesn't work, you are suppsed to declare a function as def func() and it
comes back as:

File "", line 1
 def func()
  ^
SyntaxError: invalid syntax

that is not expected I would also expect def to turn red because it is a
keyword in Python, but that doesn't happen, anyone else having this
problem Anyone know what I should do or look for
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


[Tutor] mixing 64 bit and 32 bit

2014-03-19 Thread John Fabiani

Hi,

At my office we have a mix of XP (32bit) and Window 7 (64 bit).  I 
installed python 64 bit on the windows 7 machines and 32 bit on the XP 
machines.  The question is can the different version run the same code 
without causing issues.  Can the 64 bit use the same byte code as the 32 
bit?  It seems to be working but I thought best to check.


Johnf
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] mixing 64 bit and 32 bit

2014-03-19 Thread John Fabiani

Thanks
Johnf
On 03/19/2014 11:01 AM, Reuben wrote:


Hi John,

The generated bytecodes will be different - but both version can run 
same code without issues


Regards,
Reuben

On 19-Mar-2014 11:28 PM, John Fabiani jo...@jfcomputer.com 
mailto:jo...@jfcomputer.com wrote:


Hi,

At my office we have a mix of XP (32bit) and Window 7 (64 bit).  I
installed python 64 bit on the windows 7 machines and 32 bit on
the XP machines.  The question is can the different version run
the same code without causing issues.  Can the 64 bit use the same
byte code as the 32 bit?  It seems to be working but I thought
best to check.

Johnf
___
Tutor maillist  - Tutor@python.org mailto:Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor



___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


[Tutor] which gets called

2012-04-06 Thread John Fabiani
Hi,

I want to create a class that inherits two other classes.

class NewClass( A,B)

But both A and B contain a method with the same name (onKeyDown). 

If my NewClass does not contain something to override the methods which one 
would be called if

myinstance = NewClass()

myinstance.onKeyDown()


Second to insure the right one is called is it possible to do the following

NewClass(object):

  def onKeyDown(self, event):
  b.onKeyDown(event)

Johnf
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] which gets called

2012-04-06 Thread John Fabiani
On Friday, April 06, 2012 06:54:28 AM John Fabiani wrote:
 Hi,
 
 I want to create a class that inherits two other classes.
 
 class NewClass( A,B)
 
 But both A and B contain a method with the same name (onKeyDown).
 
 If my NewClass does not contain something to override the methods which
 one would be called if
 
 myinstance = NewClass()
 
 myinstance.onKeyDown()
 
 
 Second to insure the right one is called is it possible to do the following
 
 NewClass(object):
 
   def onKeyDown(self, event):
   b.onKeyDown(event)
 
 Johnf

Thanks guys!

The class I'm creating is inheriting from classes I did not create.  And of 
course the inherited classes are from different authors.  So I'm attempting to 
create a wrapper and the problem comes from the keyboard events.  Each of the 
classes has a onKeyDown method and I only want one to work and then pass the 
data to the second.

But you have helped (along with the links).  And I have successfully got the 
right method called.  The issue is now getting the second (B) to fire 
correctly.

Johnf
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Windows vs Linux processing speed.

2011-10-14 Thread John Fabiani
On Friday, October 14, 2011 09:45:57 am Tony Pelletier wrote:
 Hi,
 
 I have a question regarding the speed of my program on linux in comparison
 to windows.
 
 I'm using geopy and contacting Google for geocodes for records in a csv I
 created.  Like such:
 
  try:
 reader = csv.reader(open(filename, r))
 for row in reader:
 if row: # Checking to see if it's a valid row so it doesn't
 blow up on an empty row.
 username, address, address2, city, state, zip, country =
 row[0:7]
 location = address + ', ' + city + ' ' + state + ' ' + zip
 + ' ' + country
 try:
 place, (lat, lng) =  g.geocode(location) # Contact
 Google for Geocodes
 
 I mainly use windows, but I tend to use Arch Linux at home.  When I run it
 via windows, it's relatively slow and didn't really bother me, but when I
 ran it at home I got through 15 or so and got a message back from google
 saying  I was exceeding the allowed amount.  Or something to that effect.
  Basically, I was exceeding the 10 per second that's allowed.
 
 So, my question is.  Why is it running so much faster on linux?  Is it the
 way that linux is handling the socket?  Does windows open and close it
 whereas linux might leave it open and just pump data through?
 
 It's not really a problem since I just added sleep time, but I'm curious.
 
 Thanks
 Tony

It's a very good question that I'd like to hear the answer too.  When ever I 
run pure python on linux is always runs faster (this has been my experience).  
I of course have not a clue as to why (or I might not be monitoring this 
list).  But I bet other do know!

Johnf
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Conceptual Question About Use of Python for Employee Training Program

2011-06-25 Thread John Fabiani
On Saturday, June 25, 2011 06:18:14 am Adam Carr wrote:
 Good Morning:
 
 I am very new to Python but I am enjoying the learning process. I have a
 question about the application of Python to a problem at the industrial
 business where I work. My two main questions are:
 
 1. Can Python be used to achieve the goals of the possible project?
 2. Where are the best places to look (books, blogs, websites, etc.) for
 programming examples or modules that would help me begin to assemble and
 test some code?
 
 We currently have a Windows-PC based safety training program that was put
 together in MS Access around 2001. Access has evolved through several
 versions since then, as has the Windows OS, and the original author of the
 database has left the company. Originally designed to be deployed on an
 employee's desktop, the database is now restricted to two older PCs in the
 facility that run a version of Access compatible with the original. In
 short, the program is quickly becoming obsolete.
 
 The safety training program is a monthly exercise for all thirty nine
 employees at our location. The training is mandated by OSHA, and the
 subject matter is chosen based on the relevance to our processes. The
 program consists of the following general steps.
 
 1. The employee is prompted to enter his or her employee identity number.
 
 2. A confirmation is generated showing the employee name and other minor
 details, accessed from a simple list, to be sure the identity number and
 the person are correctly matched. This requires employee acknowledgment.
 
 3. The employee freely selects a training subject from a list.
 
 4. Once a subject is selected, a PowerPoint (or could be the OpenOffice
 Presentation) is launched. The training information is in the presentation.
 The employee can navigate forward or backward through the presentation, or
 they can exit.
 
 5. Once the presentation is complete, or the employee has started and used
 ESC to exit from the presentation, they are prompted to take a quiz or
 exit the training program.
 
 6. The quiz is a simple true-false ten question process based on the
 material in the training presentation.
 
 7. The employee clicks on their answers to questions, the quiz is completed
 and scored. The employee must get at least eight of the ten questions
 correct to pass the topic.
 
 
 8. Right now the Access version of the program prints the quiz, the
 employee's answers and the correct answers to the quiz, and the hard copy
 is signed and left with their supervisor. The printer is the default
 location set for the machine on which the training and quiz are completed.
 I think that the only reason the quizzes are printed is because no topic
 and quiz verification process was written into the program. In other
 words, an employee can take the time to review a topic, take and pass the
 associated quiz but if the printed copy is lost there is no way to verify
 that the employee completed anything.
 
 
 I would like to see a program that can be deployed as originally intended,
 on individual PCs, that can be more easily maintained and modified than the
 behemoth Access program we now have. We are running a Windows network with
 most production floor PCs using the latest version of XP and most
 individual desktops and laptops using Windows 7. I have the blessing of
 our network gods to pursue an open source solution because the options for
 this kind of program, which is tailored to individual locations, are few.
 The best approach the network folks suggested was a Lotus Notes database,
 which would work great I'm sure but the development cost is very, very
 high and each of the company's many manufacturing locations would require
 a slightly different version of the database.
 
 Thanks in advance for taking the time to read my long note. I appreciate
 any help or direction that can be offered.
 
 Adam
You might want to check out Dabo (www.dabodev.com).  It was designed to 
replace Visual Fox Pro, Access, and Visual Basic desktop programs.  Dabo does 
a very good job with dealing with the GUI and data.

That of course assumes you want a desktop app.  You could also use Django to 
create a web app.  But if this is your first python project I think I'd go 
with a desktop app rather than deal with HTML, JavaSript, CSS, and python for 
the first project.  

Johnf

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Looking for a firebird interface

2005-01-05 Thread John Fabiani
Thanks all I fixed it.
John
On Tuesday 04 January 2005 21:30, John Fabiani wrote:
 Hi,
 I'm using SUSE x86_64 Linux and unable to compile the KInterbasdb interface
 for Python.  I'm wondering if anyone has it compiled on either a 32bit or
 64bit linux.  Of course I'm hoping someone is willing to post it. Or tell
 me where I might get it.  Thanks in advance.
 John
 ___
 Tutor maillist  -  Tutor@python.org
 http://mail.python.org/mailman/listinfo/tutor
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Looking for a firebird interface

2005-01-04 Thread John Fabiani
Hi,
I'm using SUSE x86_64 Linux and unable to compile the KInterbasdb interface 
for Python.  I'm wondering if anyone has it compiled on either a 32bit or 
64bit linux.  Of course I'm hoping someone is willing to post it. Or tell me 
where I might get it.  Thanks in advance.  
John
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor